Skip to content
This repository has been archived by the owner on Dec 26, 2024. It is now read-only.

Commit

Permalink
fix to the bug with linux "node\r"
Browse files Browse the repository at this point in the history
  • Loading branch information
crystian committed May 14, 2018
1 parent 1811ab3 commit ae45ad0
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 26 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
});
Expand Down
7 changes: 3 additions & 4 deletions lib/builders.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { mergeDeep, isObject, isObjectEmpty, isString } = require('./utils');
const { predefined } = require('./defaults');
const { mergeDeep, isObject } = require('./utils');
const { messages } = require('./i18n');

/**
Expand All @@ -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
Expand All @@ -49,7 +48,7 @@ const buildShortcutPossibilities = (shortcuts) => {
r = messages.shortcut.withoutArgumentsPossibleValues.toTemplate({ shortcuts: shortcutsMap.join(', ') });
}
}

return r;
};

Expand Down
6 changes: 3 additions & 3 deletions lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -64,7 +64,7 @@ let buildCommandWithConfig = (shortcut, config) => {
} else {
test = {
showedCommand: true,
dry: false,
dry: false
};

/* istanbul ignore if */
Expand Down
8 changes: 4 additions & 4 deletions lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
}

Expand All @@ -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 }));
}
};

Expand Down Expand Up @@ -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 }));
}
};

Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -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"
}
}
16 changes: 8 additions & 8 deletions test/builders.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"');
});
Expand Down
2 changes: 1 addition & 1 deletion test/node.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down

0 comments on commit ae45ad0

Please sign in to comment.