From 655403055099299cc8c5053af970366d0c4c32b7 Mon Sep 17 00:00:00 2001 From: Mario Nebl Date: Tue, 2 Jan 2018 08:53:34 +0100 Subject: [PATCH 01/10] Use svg screenshot --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 6955631..eb74603 100644 --- a/readme.md +++ b/readme.md @@ -13,7 +13,7 @@ ### [See what's new in Chalk 2](https://github.com/chalk/chalk/releases/tag/v2.0.0) -![](https://github.com/chalk/ansi-styles/raw/master/screenshot.png) + ## Highlights From 011dd0421e14b21a07392b8d9d28ba9e851397b4 Mon Sep 17 00:00:00 2001 From: Aman Pratap Singh Date: Sun, 11 Feb 2018 14:33:50 +0530 Subject: [PATCH 02/10] Fix usage example in the readme (#251) --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index eb74603..6a903c7 100644 --- a/readme.md +++ b/readme.md @@ -51,7 +51,7 @@ const chalk = require('chalk'); const log = console.log; // Combine styled and normal strings -log(chalk.blue('Hello') + 'World' + chalk.red('!')); +log(chalk.blue('Hello') + ' World' + chalk.red('!')); // Compose multiple styles using the chainable API log(chalk.blue.bgRed.bold('Hello world!')); From 678152cf1952f3afe1e523a306c0413ad57c34b3 Mon Sep 17 00:00:00 2001 From: Kayla Washburn Date: Sun, 11 Feb 2018 02:59:24 -0700 Subject: [PATCH 03/10] Update chalk to use the latest updates to supports-color (#247) --- index.js | 6 +++--- package.json | 2 +- test/_supports-color.js | 10 ++++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 05e62b3..1cc5fa8 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ 'use strict'; const escapeStringRegexp = require('escape-string-regexp'); const ansiStyles = require('ansi-styles'); -const supportsColor = require('supports-color'); +const stdoutColor = require('supports-color').stdout; const template = require('./templates.js'); @@ -19,7 +19,7 @@ function applyOptions(obj, options) { options = options || {}; // Detect level if not set manually - const scLevel = supportsColor ? supportsColor.level : 0; + const scLevel = stdoutColor ? stdoutColor.level : 0; obj.level = options.level === undefined ? scLevel : options.level; obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0; } @@ -224,5 +224,5 @@ function chalkTag(chalk, strings) { Object.defineProperties(Chalk.prototype, styles); module.exports = Chalk(); // eslint-disable-line new-cap -module.exports.supportsColor = supportsColor; +module.exports.supportsColor = stdoutColor; module.exports.default = module.exports; // For TypeScript diff --git a/package.json b/package.json index 69889f0..d5db4f7 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "dependencies": { "ansi-styles": "^3.1.0", "escape-string-regexp": "^1.0.5", - "supports-color": "^4.0.0" + "supports-color": "^5.0.0" }, "devDependencies": { "ava": "*", diff --git a/test/_supports-color.js b/test/_supports-color.js index d6e82bb..cfca6cc 100644 --- a/test/_supports-color.js +++ b/test/_supports-color.js @@ -4,10 +4,12 @@ const resolveFrom = require('resolve-from'); module.exports = dir => { require.cache[resolveFrom(dir, 'supports-color')] = { exports: { - level: 3, - hasBasic: true, - has256: true, - has16m: true + stdout: { + level: 3, + hasBasic: true, + has256: true, + has16m: true + } } }; }; From b55dd79f8bbd37725de562ce7422cd3ba8c87c3e Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sun, 11 Feb 2018 20:04:55 +0700 Subject: [PATCH 04/10] Force bump dependencies npm is buggy, so doing this just to be sure. --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index d5db4f7..f59fbb5 100644 --- a/package.json +++ b/package.json @@ -41,14 +41,14 @@ "text" ], "dependencies": { - "ansi-styles": "^3.1.0", + "ansi-styles": "^3.2.0", "escape-string-regexp": "^1.0.5", - "supports-color": "^5.0.0" + "supports-color": "^5.2.0" }, "devDependencies": { "ava": "*", "coveralls": "^3.0.0", - "execa": "^0.8.0", + "execa": "^0.9.0", "import-fresh": "^2.0.0", "matcha": "^0.7.0", "nyc": "^11.0.2", From ae8a03f2c5c49896adeb3dd4ec5350e4ab9449a2 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sun, 11 Feb 2018 20:18:25 +0700 Subject: [PATCH 05/10] 2.3.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f59fbb5..a02207c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chalk", - "version": "2.3.0", + "version": "2.3.1", "description": "Terminal string styling done right", "license": "MIT", "repository": "chalk/chalk", From 576d8d217179d2e913e29639586204c2c2a76dc3 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 15 Feb 2018 00:15:28 +0700 Subject: [PATCH 06/10] Update URL to XO --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 6a903c7..f96a964 100644 --- a/readme.md +++ b/readme.md @@ -9,7 +9,7 @@ > Terminal string styling done right -[![Build Status](https://travis-ci.org/chalk/chalk.svg?branch=master)](https://travis-ci.org/chalk/chalk) [![Coverage Status](https://coveralls.io/repos/github/chalk/chalk/badge.svg?branch=master)](https://coveralls.io/github/chalk/chalk?branch=master) [![](https://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://www.youtube.com/watch?v=9auOCbH5Ns4) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo) [![Mentioned in Awesome Node.js](https://awesome.re/mentioned-badge.svg)](https://github.com/sindresorhus/awesome-nodejs) +[![Build Status](https://travis-ci.org/chalk/chalk.svg?branch=master)](https://travis-ci.org/chalk/chalk) [![Coverage Status](https://coveralls.io/repos/github/chalk/chalk/badge.svg?branch=master)](https://coveralls.io/github/chalk/chalk?branch=master) [![](https://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://www.youtube.com/watch?v=9auOCbH5Ns4) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) [![Mentioned in Awesome Node.js](https://awesome.re/mentioned-badge.svg)](https://github.com/sindresorhus/awesome-nodejs) ### [See what's new in Chalk 2](https://github.com/chalk/chalk/releases/tag/v2.0.0) From 12d1276b36cc026ecea1bdfe1771198b242f7b1d Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 15 Feb 2018 00:41:45 +0700 Subject: [PATCH 07/10] Fix linting --- templates.js | 1 + test/template-literal.js | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/templates.js b/templates.js index dbdf9b2..b2a33a4 100644 --- a/templates.js +++ b/templates.js @@ -1,3 +1,4 @@ +/* eslint-disable unicorn/no-unsafe-regex */ 'use strict'; const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi; const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g; diff --git a/test/template-literal.js b/test/template-literal.js index bfa346c..117b596 100644 --- a/test/template-literal.js +++ b/test/template-literal.js @@ -126,14 +126,14 @@ test('correctly parse escape in parameters (bug #177 comment 318622809)', t => { test('correctly parses unicode/hex escapes', t => { const ctx = m.constructor({level: 0}); - t.is(ctx`\u0078ylophones are fo\x78y! {magenta.inverse \u0078ylophones are fo\x78y!}`, + t.is(ctx`\u0078ylophones are fo\u0078y! {magenta.inverse \u0078ylophones are fo\u0078y!}`, 'xylophones are foxy! xylophones are foxy!'); }); test('correctly parses string arguments', t => { const ctx = m.constructor({level: 3}); t.is(ctx`{keyword('black').bold can haz cheezburger}`, '\u001B[38;2;0;0;0m\u001B[1mcan haz cheezburger\u001B[22m\u001B[39m'); - t.is(ctx`{keyword('blac\x6B').bold can haz cheezburger}`, '\u001B[38;2;0;0;0m\u001B[1mcan haz cheezburger\u001B[22m\u001B[39m'); + t.is(ctx`{keyword('blac\u006B').bold can haz cheezburger}`, '\u001B[38;2;0;0;0m\u001B[1mcan haz cheezburger\u001B[22m\u001B[39m'); t.is(ctx`{keyword('blac\u006B').bold can haz cheezburger}`, '\u001B[38;2;0;0;0m\u001B[1mcan haz cheezburger\u001B[22m\u001B[39m'); }); @@ -159,7 +159,7 @@ test('throws if an extra unescaped } is found', t => { test('should not parse upper-case escapes', t => { const ctx = m.constructor({level: 0}); - t.is(ctx`\N\n\T\t\X07\x07\U000A\u000A\U000a\u000a`, 'N\nT\tX07\x07U000A\u000AU000a\u000A'); + t.is(ctx`\N\n\T\t\X07\u0007\U000A\u000A\U000a\u000a`, 'N\nT\tX07\u0007U000A\u000AU000a\u000A'); }); test('should properly handle undefined template interpolated values', t => { From 52823001a59ea2270c186cb41c36b0e3e0a6da37 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Wed, 14 Feb 2018 18:28:22 -0800 Subject: [PATCH 08/10] Revert "Fix linting" This reverts commit 12d1276b36cc026ecea1bdfe1771198b242f7b1d. --- templates.js | 1 - test/template-literal.js | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/templates.js b/templates.js index b2a33a4..dbdf9b2 100644 --- a/templates.js +++ b/templates.js @@ -1,4 +1,3 @@ -/* eslint-disable unicorn/no-unsafe-regex */ 'use strict'; const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi; const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g; diff --git a/test/template-literal.js b/test/template-literal.js index 117b596..bfa346c 100644 --- a/test/template-literal.js +++ b/test/template-literal.js @@ -126,14 +126,14 @@ test('correctly parse escape in parameters (bug #177 comment 318622809)', t => { test('correctly parses unicode/hex escapes', t => { const ctx = m.constructor({level: 0}); - t.is(ctx`\u0078ylophones are fo\u0078y! {magenta.inverse \u0078ylophones are fo\u0078y!}`, + t.is(ctx`\u0078ylophones are fo\x78y! {magenta.inverse \u0078ylophones are fo\x78y!}`, 'xylophones are foxy! xylophones are foxy!'); }); test('correctly parses string arguments', t => { const ctx = m.constructor({level: 3}); t.is(ctx`{keyword('black').bold can haz cheezburger}`, '\u001B[38;2;0;0;0m\u001B[1mcan haz cheezburger\u001B[22m\u001B[39m'); - t.is(ctx`{keyword('blac\u006B').bold can haz cheezburger}`, '\u001B[38;2;0;0;0m\u001B[1mcan haz cheezburger\u001B[22m\u001B[39m'); + t.is(ctx`{keyword('blac\x6B').bold can haz cheezburger}`, '\u001B[38;2;0;0;0m\u001B[1mcan haz cheezburger\u001B[22m\u001B[39m'); t.is(ctx`{keyword('blac\u006B').bold can haz cheezburger}`, '\u001B[38;2;0;0;0m\u001B[1mcan haz cheezburger\u001B[22m\u001B[39m'); }); @@ -159,7 +159,7 @@ test('throws if an extra unescaped } is found', t => { test('should not parse upper-case escapes', t => { const ctx = m.constructor({level: 0}); - t.is(ctx`\N\n\T\t\X07\u0007\U000A\u000A\U000a\u000a`, 'N\nT\tX07\u0007U000A\u000AU000a\u000A'); + t.is(ctx`\N\n\T\t\X07\x07\U000A\u000A\U000a\u000a`, 'N\nT\tX07\x07U000A\u000AU000a\u000A'); }); test('should properly handle undefined template interpolated values', t => { From 925397a0f5d7f17605eaabd6ee3bb26d77280d2d Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Wed, 14 Feb 2018 18:29:19 -0800 Subject: [PATCH 09/10] Disable unicorn/no-unsafe-regex for template parser --- templates.js | 1 + 1 file changed, 1 insertion(+) diff --git a/templates.js b/templates.js index dbdf9b2..b2a33a4 100644 --- a/templates.js +++ b/templates.js @@ -1,3 +1,4 @@ +/* eslint-disable unicorn/no-unsafe-regex */ 'use strict'; const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi; const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g; From e80f02e2ddae53b897fa2d9751d5d86fae493b45 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Wed, 14 Feb 2018 18:30:01 -0800 Subject: [PATCH 10/10] Disable unicorn/no-hex-escape for template tests --- test/template-literal.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/template-literal.js b/test/template-literal.js index bfa346c..71cc106 100644 --- a/test/template-literal.js +++ b/test/template-literal.js @@ -1,3 +1,4 @@ +/* eslint-disable unicorn/no-hex-escape */ import test from 'ava'; // Spoof supports-color