From ae45ad0127fecb155dcd66213bb9acd8c909e7fd Mon Sep 17 00:00:00 2001 From: pusher Date: Mon, 14 May 2018 20:41:20 -0300 Subject: [PATCH] fix to the bug with linux "node\r" --- .editorconfig | 13 +++++++++++++ bin/index.js | 6 +++--- lib/builders.js | 7 +++---- lib/command.js | 6 +++--- lib/node.js | 8 ++++---- package.json | 5 ++--- test/builders.spec.js | 16 ++++++++-------- test/node.spec.js | 2 +- 8 files changed, 37 insertions(+), 26 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..fa8d8c5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +root = true + +[*] +charset = utf-8 +indent_style = tab +insert_final_newline = true +trim_trailing_whitespace = true +end_of_line = lf +insert_final_newline = true + +[*.md] +max_line_length = off +trim_trailing_whitespace = false diff --git a/bin/index.js b/bin/index.js index 73f5090..0c5342e 100644 --- a/bin/index.js +++ b/bin/index.js @@ -25,7 +25,7 @@ let timestamp = new Date(); try { result = buildCommand(shortcut); } catch(e) { - console.log(`\n[${messages.app.name}]`,`${e.message}\n`); + console.log(`\n[${messages.app.name}]`, `${e.message}\n`); process.exit(1); } @@ -38,8 +38,8 @@ if (!result.config.config.dry) { }); child.on('close', (code) => { - if(result.config.config.showTime){ - console.primary(`[${messages.app.name}]`, `Done in: ${(new Date() - timestamp) / 1000}s`); + if (result.config.config.showTime) { + console.primary(`[${messages.app.name}]`, `Done in: ${(new Date() - timestamp) / 1000}s`); } process.exit(code); }); diff --git a/lib/builders.js b/lib/builders.js index 38dca28..3851b9b 100644 --- a/lib/builders.js +++ b/lib/builders.js @@ -1,5 +1,4 @@ -const { mergeDeep, isObject, isObjectEmpty, isString } = require('./utils'); -const { predefined } = require('./defaults'); +const { mergeDeep, isObject } = require('./utils'); const { messages } = require('./i18n'); /** @@ -23,7 +22,7 @@ const buildConfig = (configDefault, config) => { */ const buildShortcutCommand = (shortcuts, shortcut) => { shortcut = shortcut.split(' '); - let log = messages.shortcut.notFoundFirstShortcut.toTemplate({shortcut}) + buildShortcutPossibilities(shortcuts), + let log = messages.shortcut.notFoundFirstShortcut.toTemplate({ shortcut }) + buildShortcutPossibilities(shortcuts), command = _buildShortcutRecursive(shortcuts, shortcut, log); // this add final arguments to the command line @@ -49,7 +48,7 @@ const buildShortcutPossibilities = (shortcuts) => { r = messages.shortcut.withoutArgumentsPossibleValues.toTemplate({ shortcuts: shortcutsMap.join(', ') }); } } - + return r; }; diff --git a/lib/command.js b/lib/command.js index 2f78ccc..9e917c7 100644 --- a/lib/command.js +++ b/lib/command.js @@ -46,14 +46,14 @@ let buildCommandWithConfig = (shortcut, config) => { let test = { showedCommand: false, - dry: false, + dry: false }; if ((config.config.dry || config.config.showCommand)) { if (config.config.dry) { test = { showedCommand: true, - dry: true, + dry: true }; /* istanbul ignore if */ @@ -64,7 +64,7 @@ let buildCommandWithConfig = (shortcut, config) => { } else { test = { showedCommand: true, - dry: false, + dry: false }; /* istanbul ignore if */ diff --git a/lib/node.js b/lib/node.js index 14d5c77..eb2319a 100644 --- a/lib/node.js +++ b/lib/node.js @@ -48,11 +48,11 @@ let getConfigFileName = (filePath) => { throw new Error(messages.config.isNotAString); } } - + /* istanbul ignore if */ if (!isTestRunning()) { // it is ok, I can use "console.primary" because I don't have the configuration to finish with this - console.log('\x1b[37m%s\x1b[0m', `[${messages.app.name}]`, messages.config.used.toTemplate({configFileName})); + console.log('\x1b[37m%s\x1b[0m', `[${messages.app.name}]`, messages.config.used.toTemplate({ configFileName })); } } @@ -72,7 +72,7 @@ let getContentJsonFile = (jsonFile) => { try { return JSON.parse(contentFile); } catch(e) { - throw new Error(messages.config.invalidJson.toTemplate({jsonFile})); + throw new Error(messages.config.invalidJson.toTemplate({ jsonFile })); } }; @@ -105,7 +105,7 @@ let getContentFile = (fileName) => { if (fs.existsSync(fileName)) { return fs.readFileSync(fileName, 'utf8'); } else { - throw new Error(messages.config.notFound.toTemplate({fileName})); + throw new Error(messages.config.notFound.toTemplate({ fileName })); } }; diff --git a/package.json b/package.json index aa5f25e..b92c7b0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "executor", - "version": "0.0.12-beta", + "version": "0.0.13-beta", "license": "MIT", "description": "A powerful \"short-cutter\" to your console for you and your team!", "scripts": { @@ -62,9 +62,8 @@ "bugs": { "url": "https://github.com/crystian/executor/issues" }, - "engineStrict" : true, "engines": { "node": ">=8.11.0", - "npm" : ">=5.6.0" + "npm": ">=5.6.0" } } diff --git a/test/builders.spec.js b/test/builders.spec.js index 609a901..c43e2d2 100644 --- a/test/builders.spec.js +++ b/test/builders.spec.js @@ -185,29 +185,29 @@ describe('buildShortcutCommand() results', function() { describe('buildShortcutPosibilities() results', function() { - it('should return a string without possibilities', ()=>{ + it('should return a string without possibilities', () => { let r = buildShortcutPossibilities(); assert.equal(r, ''); }); - it('should return a string without possibilities', ()=>{ + it('should return a string without possibilities', () => { let r = buildShortcutPossibilities({}); assert.equal(r, ''); }); - it('should return a string without possibilities', ()=>{ + it('should return a string without possibilities', () => { let r = buildShortcutPossibilities(1); assert.equal(r, ''); }); - it('should return a string without possibilities', ()=>{ + it('should return a string without possibilities', () => { let r = buildShortcutPossibilities([]); assert.equal(r, ''); }); - it('should return a string with a possibility', ()=>{ - let r = buildShortcutPossibilities({key1: 'key1'}); + it('should return a string with a possibility', () => { + let r = buildShortcutPossibilities({ key1: 'key1' }); assert.include(r, '"key1"'); }); - it('should return a string with two possibility', ()=>{ - let r = buildShortcutPossibilities({key1: 'key1', key2: 'key2'}); + it('should return a string with two possibility', () => { + let r = buildShortcutPossibilities({ key1: 'key1', key2: 'key2' }); assert.include(r, '"key1"'); assert.include(r, '"key2"'); }); diff --git a/test/node.spec.js b/test/node.spec.js index 3a779d3..fa6ccb4 100644 --- a/test/node.spec.js +++ b/test/node.spec.js @@ -42,7 +42,7 @@ describe('getConfig() throws', function() { afterEach('', () => { process.chdir(cwd); }); - + it('should throw an error by does not exist the configuration file', function() { process.chdir('test/fixture/01');