From 8b51cf67b549733ea05b091b6ca53c009d9918fe Mon Sep 17 00:00:00 2001 From: Geraint White Date: Fri, 10 Apr 2015 22:56:26 +0100 Subject: [PATCH 01/18] Fix #119 - use util.inspect for logging objects --- lib/colors.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/colors.js b/lib/colors.js index 59898de..1b6c240 100644 --- a/lib/colors.js +++ b/lib/colors.js @@ -2,7 +2,7 @@ The MIT License (MIT) -Original Library +Original Library - Copyright (c) Marak Squires Additional functionality @@ -33,6 +33,7 @@ module['exports'] = colors; colors.themes = {}; +var util = require('util'); var ansiStyles = colors.styles = require('./styles'); var defineProps = Object.defineProperties; @@ -87,14 +88,11 @@ var styles = (function () { var proto = defineProps(function colors() {}, styles); function applyStyle() { - var args = arguments; - var argsLen = args.length; - var str = argsLen !== 0 && String(arguments[0]); - if (argsLen > 1) { - for (var a = 1; a < argsLen; a++) { - str += ' ' + args[a]; - } - } + var args = Array.prototype.slice.call(arguments); + + var str = args.map(function(arg) { + return typeof arg === 'object' ? util.inspect(arg) : arg; + }).join(' '); if (!colors.enabled || !str) { return str; @@ -173,4 +171,4 @@ for (var map in colors.maps) { })(map) } -defineProps(colors, init()); \ No newline at end of file +defineProps(colors, init()); From 255c07877296ced2ba2353f984b49ee7e1a349aa Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Thu, 12 Jan 2017 09:37:25 +0800 Subject: [PATCH 02/18] Update extendStringPrototype.js Remove ununused function and fix method name in blacklist --- lib/extendStringPrototype.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/extendStringPrototype.js b/lib/extendStringPrototype.js index 67374a1..6c04c87 100644 --- a/lib/extendStringPrototype.js +++ b/lib/extendStringPrototype.js @@ -9,14 +9,6 @@ module['exports'] = function () { String.prototype.__defineGetter__(color, func); }; - var sequencer = function sequencer (map, str) { - return function () { - var exploded = this.split(""), i = 0; - exploded = exploded.map(map); - return exploded.join(""); - } - }; - addProperty('strip', function () { return colors.strip(this); }); @@ -67,7 +59,7 @@ module['exports'] = function () { var stringPrototypeBlacklist = [ '__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', 'charAt', 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf', 'charCodeAt', - 'indexOf', 'lastIndexof', 'length', 'localeCompare', 'match', 'replace', 'search', 'slice', 'split', 'substring', + 'indexOf', 'lastIndexOf', 'length', 'localeCompare', 'match', 'replace', 'search', 'slice', 'split', 'substring', 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toUpperCase', 'trim', 'trimLeft', 'trimRight' ]; @@ -110,4 +102,4 @@ module['exports'] = function () { } }; -}; \ No newline at end of file +}; From 81f0c320ee1c2ae12868ccbcd98896f3e4470099 Mon Sep 17 00:00:00 2001 From: DABH Date: Sun, 25 Mar 2018 12:45:20 -0700 Subject: [PATCH 03/18] Update ROADMAP.md --- ROADMAP.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index e8f0816..93dfa50 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -7,10 +7,10 @@ Here we describe upcoming releases and the key features/fixes they include. Don ### 1.3.0 * Support custom colors -### 1.2.1 +### 1.2.2 * Refactor tests to use a testing library like jest (only affects dev/testing) -### 1.2.0 (release date: about 3/5/18, barring any new issues) +~~### 1.2.0 (release date: about 3/5/18, barring any new issues) * Built-in Typescript definitions - * Key bug fixes for webpack/bundlers, webstorm, etc. + * Key bug fixes for webpack/bundlers, webstorm, etc.~~ From f572036878ec418fe7cbfcc55516957f1d3ed615 Mon Sep 17 00:00:00 2001 From: DABH Date: Sun, 25 Mar 2018 12:46:02 -0700 Subject: [PATCH 04/18] Update ROADMAP.md --- ROADMAP.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 93dfa50..6ae0743 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -10,7 +10,7 @@ Here we describe upcoming releases and the key features/fixes they include. Don ### 1.2.2 * Refactor tests to use a testing library like jest (only affects dev/testing) -~~### 1.2.0 (release date: about 3/5/18, barring any new issues) - * Built-in Typescript definitions - * Key bug fixes for webpack/bundlers, webstorm, etc.~~ +### ~~1.2.0 (release date: about 3/5/18, barring any new issues)~~ + * ~~Built-in Typescript definitions~~ + * ~~Key bug fixes for webpack/bundlers, webstorm, etc.~~ From 172098b1f56c9fa3aa4d278e1f1f2349fb75eb0b Mon Sep 17 00:00:00 2001 From: Josh Pike Date: Tue, 3 Apr 2018 13:35:15 +0700 Subject: [PATCH 05/18] Add multiline handling functionality Allows multiline logs to have each line styled properly. --- lib/colors.js | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/lib/colors.js b/lib/colors.js index 1fb08b5..dc2e9dd 100644 --- a/lib/colors.js +++ b/lib/colors.js @@ -42,14 +42,14 @@ if (typeof colors.enabled === "undefined") { colors.enabled = colors.supportsColor() !== false; } -colors.stripColors = colors.strip = function(str){ +colors.stripColors = colors.strip = function (str) { return ("" + str).replace(/\x1B\[\d+m/g, ''); }; -var stylize = colors.stylize = function stylize (str, style) { +var stylize = colors.stylize = function stylize(str, style) { if (!colors.enabled) { - return str+''; + return str + ''; } return ansiStyles[style].open + str + ansiStyles[style].close; @@ -60,7 +60,7 @@ var escapeStringRegexp = function (str) { if (typeof str !== 'string') { throw new TypeError('Expected a string'); } - return str.replace(matchOperatorsRe, '\\$&'); + return str.replace(matchOperatorsRe, '\\$&'); } function build(_styles) { @@ -88,7 +88,7 @@ var styles = (function () { return ret; })(); -var proto = defineProps(function colors() {}, styles); +var proto = defineProps(function colors() { }, styles); function applyStyle() { var args = arguments; @@ -107,12 +107,23 @@ function applyStyle() { var nestedStyles = this._styles; var i = nestedStyles.length; + + var rebuiltString = ''; + while (i--) { var code = ansiStyles[nestedStyles[i]]; - str = code.open + str.replace(code.closeRe, code.open) + code.close; + + // multiline handling functionality + var lines = str.split(/[\r\n]+/) + var rebuiltString = ''; + lines.forEach(line => { + rebuiltString += (code.open + line.replace(code.closeRe, code.open) + code.close + '\n') + }) + } - return str; + return rebuiltString; + } colors.setTheme = function (theme) { @@ -124,11 +135,11 @@ colors.setTheme = function (theme) { return; } for (var style in theme) { - (function(style){ - colors[style] = function(str){ - if (typeof theme[style] === 'object'){ + (function (style) { + colors[style] = function (str) { + if (typeof theme[style] === 'object') { var out = str; - for (var i in theme[style]){ + for (var i in theme[style]) { out = colors[theme[style][i]](out); } return out; @@ -151,7 +162,7 @@ function init() { return ret; } -var sequencer = function sequencer (map, str) { +var sequencer = function sequencer(map, str) { var exploded = str.split(""), i = 0; exploded = exploded.map(map); return exploded.join(""); @@ -169,7 +180,7 @@ colors.maps.rainbow = require('./maps/rainbow'); colors.maps.random = require('./maps/random') for (var map in colors.maps) { - (function(map){ + (function (map) { colors[map] = function (str) { return sequencer(colors.maps[map], str); } From e020f97ea9708a6dc6c81fee79a638f9c19f91c1 Mon Sep 17 00:00:00 2001 From: Josh Pike Date: Tue, 3 Apr 2018 13:42:53 +0700 Subject: [PATCH 06/18] Fixed test case Test failed because /n was appended even when line count was 1 --- lib/colors.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/colors.js b/lib/colors.js index dc2e9dd..c0a1835 100644 --- a/lib/colors.js +++ b/lib/colors.js @@ -107,7 +107,7 @@ function applyStyle() { var nestedStyles = this._styles; var i = nestedStyles.length; - + var rebuiltString = ''; while (i--) { @@ -116,10 +116,14 @@ function applyStyle() { // multiline handling functionality var lines = str.split(/[\r\n]+/) var rebuiltString = ''; - lines.forEach(line => { - rebuiltString += (code.open + line.replace(code.closeRe, code.open) + code.close + '\n') - }) - + if (lines == 1) { + rebuiltString += code.open + line.replace(code.closeRe, code.open) + code.close + } else { + lines.forEach(line => { + rebuiltString += code.open + line.replace(code.closeRe, code.open) + code.close + '\n' + }) + } + } return rebuiltString; From 00ee8f1ecd4416a5120c9023466684dc076285fd Mon Sep 17 00:00:00 2001 From: Josh Pike Date: Tue, 3 Apr 2018 13:45:37 +0700 Subject: [PATCH 07/18] Fixed typo --- lib/colors.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/colors.js b/lib/colors.js index c0a1835..77918a9 100644 --- a/lib/colors.js +++ b/lib/colors.js @@ -115,7 +115,6 @@ function applyStyle() { // multiline handling functionality var lines = str.split(/[\r\n]+/) - var rebuiltString = ''; if (lines == 1) { rebuiltString += code.open + line.replace(code.closeRe, code.open) + code.close } else { From b674514f1b7cebedd978673dfb3b2379871e464d Mon Sep 17 00:00:00 2001 From: Bastien Caudan Date: Mon, 9 Apr 2018 08:16:20 +0200 Subject: [PATCH 08/18] Expose enable/disable methods closes #221 --- index.d.ts | 2 ++ lib/colors.js | 10 +++++++++- safe.d.ts | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index db72fab..faa9ab6 100644 --- a/index.d.ts +++ b/index.d.ts @@ -46,6 +46,8 @@ export interface Color { zalgo: Color; } +export function enable(): void; +export function disable(): void; export function setTheme(theme: any): void; export let enabled: boolean; diff --git a/lib/colors.js b/lib/colors.js index 1fb08b5..335517d 100644 --- a/lib/colors.js +++ b/lib/colors.js @@ -2,7 +2,7 @@ The MIT License (MIT) -Original Library +Original Library - Copyright (c) Marak Squires Additional functionality @@ -42,6 +42,14 @@ if (typeof colors.enabled === "undefined") { colors.enabled = colors.supportsColor() !== false; } +colors.enable = function () { + colors.enabled = true; +}; + +colors.disable = function () { + colors.enabled = false; +}; + colors.stripColors = colors.strip = function(str){ return ("" + str).replace(/\x1B\[\d+m/g, ''); }; diff --git a/safe.d.ts b/safe.d.ts index 87f5ef2..9c81946 100644 --- a/safe.d.ts +++ b/safe.d.ts @@ -4,6 +4,8 @@ // Definitions: https://github.com/Marak/colors.js export const enabled: boolean; +export function enable(): void; +export function disable(): void; export function strip(str: string): string; export function stripColors(str: string): string; From dc1ea49d2babb48b2a7d4e51b76096f316fca72b Mon Sep 17 00:00:00 2001 From: Bastien Caudan Date: Mon, 9 Apr 2018 08:17:47 +0200 Subject: [PATCH 09/18] Add missing setTheme definition --- safe.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/safe.d.ts b/safe.d.ts index 9c81946..2bafc27 100644 --- a/safe.d.ts +++ b/safe.d.ts @@ -6,6 +6,7 @@ export const enabled: boolean; export function enable(): void; export function disable(): void; +export function setTheme(theme: any): void; export function strip(str: string): string; export function stripColors(str: string): string; From 01bb5cf845e408a79308e052ca6a5a652aad3e09 Mon Sep 17 00:00:00 2001 From: Josh Pike Date: Mon, 16 Apr 2018 12:02:15 +0700 Subject: [PATCH 10/18] fixed spacing, condensed line replacement call --- lib/colors.js | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/lib/colors.js b/lib/colors.js index 77918a9..43f83ab 100644 --- a/lib/colors.js +++ b/lib/colors.js @@ -42,14 +42,14 @@ if (typeof colors.enabled === "undefined") { colors.enabled = colors.supportsColor() !== false; } -colors.stripColors = colors.strip = function (str) { +colors.stripColors = colors.strip = function(str){ return ("" + str).replace(/\x1B\[\d+m/g, ''); }; -var stylize = colors.stylize = function stylize(str, style) { +var stylize = colors.stylize = function stylize (str, style) { if (!colors.enabled) { - return str + ''; + return str+''; } return ansiStyles[style].open + str + ansiStyles[style].close; @@ -60,7 +60,7 @@ var escapeStringRegexp = function (str) { if (typeof str !== 'string') { throw new TypeError('Expected a string'); } - return str.replace(matchOperatorsRe, '\\$&'); + return str.replace(matchOperatorsRe, '\\$&'); } function build(_styles) { @@ -88,7 +88,7 @@ var styles = (function () { return ret; })(); -var proto = defineProps(function colors() { }, styles); +var proto = defineProps(function colors() {}, styles); function applyStyle() { var args = arguments; @@ -107,26 +107,14 @@ function applyStyle() { var nestedStyles = this._styles; var i = nestedStyles.length; - - var rebuiltString = ''; - while (i--) { var code = ansiStyles[nestedStyles[i]]; - - // multiline handling functionality - var lines = str.split(/[\r\n]+/) - if (lines == 1) { - rebuiltString += code.open + line.replace(code.closeRe, code.open) + code.close - } else { - lines.forEach(line => { - rebuiltString += code.open + line.replace(code.closeRe, code.open) + code.close + '\n' - }) - } - + str = code.open + str.replace(code.closeRe, code.open) + code.close; + str = str.replace(new RegExp(/[\r\n]+/, 'g'), code.close + '\n' + code.open); } - return rebuiltString; - + return str; + } colors.setTheme = function (theme) { @@ -138,11 +126,11 @@ colors.setTheme = function (theme) { return; } for (var style in theme) { - (function (style) { - colors[style] = function (str) { - if (typeof theme[style] === 'object') { + (function(style){ + colors[style] = function(str){ + if (typeof theme[style] === 'object'){ var out = str; - for (var i in theme[style]) { + for (var i in theme[style]){ out = colors[theme[style][i]](out); } return out; @@ -165,7 +153,7 @@ function init() { return ret; } -var sequencer = function sequencer(map, str) { +var sequencer = function sequencer (map, str) { var exploded = str.split(""), i = 0; exploded = exploded.map(map); return exploded.join(""); @@ -183,11 +171,11 @@ colors.maps.rainbow = require('./maps/rainbow'); colors.maps.random = require('./maps/random') for (var map in colors.maps) { - (function (map) { + (function(map){ colors[map] = function (str) { return sequencer(colors.maps[map], str); } })(map) } -defineProps(colors, init()); +defineProps(colors, init()); \ No newline at end of file From 5fe02b870b64f7944801a9328f33a39e2c971941 Mon Sep 17 00:00:00 2001 From: Josh Pike Date: Mon, 16 Apr 2018 12:08:00 +0700 Subject: [PATCH 11/18] fixed compatibility issues with node <=5 --- lib/colors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/colors.js b/lib/colors.js index 43f83ab..13b0085 100644 --- a/lib/colors.js +++ b/lib/colors.js @@ -110,7 +110,7 @@ function applyStyle() { while (i--) { var code = ansiStyles[nestedStyles[i]]; str = code.open + str.replace(code.closeRe, code.open) + code.close; - str = str.replace(new RegExp(/[\r\n]+/, 'g'), code.close + '\n' + code.open); + str = str.replace(new RegExp(/[\r\n]+/g), code.close + '\n' + code.open); } return str; From c067109a2912833b9c668d43dcb079de6fa7b95a Mon Sep 17 00:00:00 2001 From: DABH Date: Sun, 15 Apr 2018 22:18:32 -0700 Subject: [PATCH 12/18] rm blank line --- lib/colors.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/colors.js b/lib/colors.js index 13b0085..eb27302 100644 --- a/lib/colors.js +++ b/lib/colors.js @@ -114,7 +114,6 @@ function applyStyle() { } return str; - } colors.setTheme = function (theme) { @@ -178,4 +177,4 @@ for (var map in colors.maps) { })(map) } -defineProps(colors, init()); \ No newline at end of file +defineProps(colors, init()); From 373be07fab9f71edd44c04b2ade5e4aa74f893c2 Mon Sep 17 00:00:00 2001 From: Josh Pike Date: Mon, 23 Apr 2018 17:10:59 +0700 Subject: [PATCH 13/18] Performance related tweaks --- lib/colors.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/colors.js b/lib/colors.js index 13b0085..7fa952f 100644 --- a/lib/colors.js +++ b/lib/colors.js @@ -35,6 +35,7 @@ colors.themes = {}; var ansiStyles = colors.styles = require('./styles'); var defineProps = Object.defineProperties; +var newLineRegex = new RegExp(/[\r\n]+/g); colors.supportsColor = require('./system/supports-colors').supportsColor; @@ -104,13 +105,20 @@ function applyStyle() { return str; } + var newLinesPresent = false; + if(str.indexOf('\n') != -1){ + newLinesPresent = true; + } + var nestedStyles = this._styles; var i = nestedStyles.length; while (i--) { var code = ansiStyles[nestedStyles[i]]; str = code.open + str.replace(code.closeRe, code.open) + code.close; - str = str.replace(new RegExp(/[\r\n]+/g), code.close + '\n' + code.open); + if(newLinesPresent){ + str = str.replace(newLineRegex, code.close + '\n' + code.open); + } } return str; From 0a5a26c5e8d0019091978cf73be1533356035f39 Mon Sep 17 00:00:00 2001 From: DABH Date: Mon, 23 Apr 2018 15:41:19 -0700 Subject: [PATCH 14/18] style nits --- lib/colors.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/colors.js b/lib/colors.js index 7a5a980..0b39272 100644 --- a/lib/colors.js +++ b/lib/colors.js @@ -105,10 +105,7 @@ function applyStyle() { return str; } - var newLinesPresent = false; - if(str.indexOf('\n') != -1){ - newLinesPresent = true; - } + var newLinesPresent = str.indexOf('\n') != -1; var nestedStyles = this._styles; @@ -116,7 +113,7 @@ function applyStyle() { while (i--) { var code = ansiStyles[nestedStyles[i]]; str = code.open + str.replace(code.closeRe, code.open) + code.close; - if(newLinesPresent){ + if (newLinesPresent){ str = str.replace(newLineRegex, code.close + '\n' + code.open); } } From 21448e0e9c25e1aac018539de4871feece616b93 Mon Sep 17 00:00:00 2001 From: Josh Pike Date: Thu, 26 Apr 2018 15:54:22 +0700 Subject: [PATCH 15/18] improved tests to handle newlines --- tests/basic-test.js | 21 +++++++++++++++++---- tests/safe-test.js | 21 +++++++++++++++++---- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/tests/basic-test.js b/tests/basic-test.js index fda8af4..b22a9e7 100644 --- a/tests/basic-test.js +++ b/tests/basic-test.js @@ -1,5 +1,5 @@ var assert = require('assert'), - colors = require('../lib/index'); + colors = require('../lib/index'); var s = 'string'; @@ -43,8 +43,21 @@ aE(s, 'yellow', 33); assert.equal(s, 'string'); -colors.setTheme({error:'red'}); +var testStringWithNewLines = s + ` +` + s; -assert.equal(typeof("astring".red),'string'); -assert.equal(typeof("astring".error),'string'); +// single style +assert.equal(testStringWithNewLines.red, '\x1b[31m' + s + '\n' + s + '\x1b[39m'); +var testStringWithNewLinesStyled = s.underline + ` +` + s.bold; + +// nested styles +assert.equal(testStringWithNewLinesStyled.red, '\x1b[31m' + '\x1b[4m' + s + '\x1b[24m' + '\n' + '\x1b[1m' + s + '\x1b[22m' + '\x1b[39m'); + +colors.setTheme({ error: 'red' }); + +assert.equal(typeof ("astring".red), 'string'); +assert.equal(typeof ("astring".error), 'string'); + +assert.equal(s, 'string'); diff --git a/tests/safe-test.js b/tests/safe-test.js index daad4f9..7d13129 100644 --- a/tests/safe-test.js +++ b/tests/safe-test.js @@ -1,5 +1,5 @@ var assert = require('assert'), - colors = require('../safe'); + colors = require('../safe'); var s = 'string'; @@ -39,7 +39,20 @@ aE(s, 'red', 31); aE(s, 'yellow', 33); assert.equal(s, 'string'); -colors.setTheme({error:'red'}); -assert.equal(typeof(colors.red("astring")), 'string'); -assert.equal(typeof(colors.error("astring")), 'string'); \ No newline at end of file +var testStringWithNewLines = s + ` +` + s; + +// single style +assert.equal(colors.red(testStringWithNewLines), '\x1b[31m' + s + '\x1b[39m' + '\n' + '\x1b[31m' + s + '\x1b[39m'); + +var testStringWithNewLinesStyled = colors.underline(s) + ` +` + colors.bold(s); + +// nested styles +assert.equal(colors.red(testStringWithNewLinesStyled), '\x1b[31m' + '\x1b[4m' + s + '\x1b[24m' + '\x1b[39m' + '\n' + '\x1b[31m' + '\x1b[1m' + s + '\x1b[22m' + '\x1b[39m'); + +colors.setTheme({ error: 'red' }); + +assert.equal(typeof (colors.red("astring")), 'string'); +assert.equal(typeof (colors.error("astring")), 'string'); \ No newline at end of file From 118cb0a9eca0cb81fd999602ccb5fe7cc9f816ca Mon Sep 17 00:00:00 2001 From: Josh Pike Date: Thu, 26 Apr 2018 15:59:18 +0700 Subject: [PATCH 16/18] used older syntax for tests for old node versions --- tests/basic-test.js | 6 ++---- tests/safe-test.js | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/basic-test.js b/tests/basic-test.js index b22a9e7..4924be1 100644 --- a/tests/basic-test.js +++ b/tests/basic-test.js @@ -43,14 +43,12 @@ aE(s, 'yellow', 33); assert.equal(s, 'string'); -var testStringWithNewLines = s + ` -` + s; +var testStringWithNewLines = s + '\n' + s; // single style assert.equal(testStringWithNewLines.red, '\x1b[31m' + s + '\n' + s + '\x1b[39m'); -var testStringWithNewLinesStyled = s.underline + ` -` + s.bold; +var testStringWithNewLinesStyled = s.underline + '\n' + s.bold; // nested styles assert.equal(testStringWithNewLinesStyled.red, '\x1b[31m' + '\x1b[4m' + s + '\x1b[24m' + '\n' + '\x1b[1m' + s + '\x1b[22m' + '\x1b[39m'); diff --git a/tests/safe-test.js b/tests/safe-test.js index 7d13129..1d8a5aa 100644 --- a/tests/safe-test.js +++ b/tests/safe-test.js @@ -40,14 +40,12 @@ aE(s, 'yellow', 33); assert.equal(s, 'string'); -var testStringWithNewLines = s + ` -` + s; +var testStringWithNewLines = s + '\n' + s; // single style assert.equal(colors.red(testStringWithNewLines), '\x1b[31m' + s + '\x1b[39m' + '\n' + '\x1b[31m' + s + '\x1b[39m'); -var testStringWithNewLinesStyled = colors.underline(s) + ` -` + colors.bold(s); +var testStringWithNewLinesStyled = colors.underline(s) + '\n' + colors.bold(s); // nested styles assert.equal(colors.red(testStringWithNewLinesStyled), '\x1b[31m' + '\x1b[4m' + s + '\x1b[24m' + '\x1b[39m' + '\n' + '\x1b[31m' + '\x1b[1m' + s + '\x1b[22m' + '\x1b[39m'); From 410397a5fb66bcdb79c96fa57f6e4d3cca783474 Mon Sep 17 00:00:00 2001 From: DABH Date: Mon, 30 Apr 2018 11:32:50 -0700 Subject: [PATCH 17/18] style nits --- .gitignore | 1 + tests/basic-test.js | 2 +- tests/safe-test.js | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..78fd378 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +**/*.sw* diff --git a/tests/basic-test.js b/tests/basic-test.js index 4924be1..9c17ed4 100644 --- a/tests/basic-test.js +++ b/tests/basic-test.js @@ -1,5 +1,5 @@ var assert = require('assert'), - colors = require('../lib/index'); + colors = require('../lib/index'); var s = 'string'; diff --git a/tests/safe-test.js b/tests/safe-test.js index 1d8a5aa..c8388f3 100644 --- a/tests/safe-test.js +++ b/tests/safe-test.js @@ -1,5 +1,5 @@ var assert = require('assert'), - colors = require('../safe'); + colors = require('../safe'); var s = 'string'; @@ -53,4 +53,5 @@ assert.equal(colors.red(testStringWithNewLinesStyled), '\x1b[31m' + '\x1b[4m' + colors.setTheme({ error: 'red' }); assert.equal(typeof (colors.red("astring")), 'string'); -assert.equal(typeof (colors.error("astring")), 'string'); \ No newline at end of file +assert.equal(typeof (colors.error("astring")), 'string'); + From f35a3325b014ed7d03dc5018bf20b93a4483ead6 Mon Sep 17 00:00:00 2001 From: DABH Date: Mon, 30 Apr 2018 11:36:25 -0700 Subject: [PATCH 18/18] bump version 1.2.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a24614a..7c39b8b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "colors", "description": "get colors in your node.js console", - "version": "1.2.1", + "version": "1.2.2", "author": "Marak Squires", "homepage": "https://github.com/Marak/colors.js", "bugs": "https://github.com/Marak/colors.js/issues",