Skip to content

Commit

Permalink
src,tools: use template literals
Browse files Browse the repository at this point in the history
Convert string concatenation to template literals. Enforce with lint
rule.
  • Loading branch information
Trott committed Mar 19, 2016
1 parent a53b2ac commit 92a0d69
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
rules:
# ECMAScript-6
# http://eslint.org/docs/rules/#ecmascript-6
prefer-template: 2
# Custom rules in tools/eslint-rules
buffer-constructor: 2
16 changes: 8 additions & 8 deletions src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,19 +566,19 @@
module.paths = Module._nodeModulePaths(cwd);
var script = process._eval;
var body = script;
script = 'global.__filename = ' + JSON.stringify(name) + ';\n' +
script = `global.__filename = ${JSON.stringify(name)};\n` +
'global.exports = exports;\n' +
'global.module = module;\n' +
'global.__dirname = __dirname;\n' +
'global.require = require;\n' +
'return require("vm").runInThisContext(' +
JSON.stringify(body) + ', { filename: ' +
JSON.stringify(name) + ', displayErrors: true });\n';
`${JSON.stringify(body)}, { filename: ` +
`${JSON.stringify(name)}, displayErrors: true });\n`;
// Defer evaluation for a tick. This is a workaround for deferred
// events not firing when evaluating scripts from the command line,
// see https://github.com/nodejs/node/issues/1600.
process.nextTick(function() {
var result = module._compile(script, name + '-wrapper');
var result = module._compile(script, `${name}-wrapper`);
if (process._print_eval) console.log(result);
});
}
Expand Down Expand Up @@ -770,7 +770,7 @@
sig.slice(0, 3) === 'SIG') {
err = process._kill(pid, startup.lazyConstants()[sig]);
} else {
throw new Error('Unknown signal: ' + sig);
throw new Error(`Unknown signal: ${sig}`);
}
}

Expand Down Expand Up @@ -875,7 +875,7 @@
}

function NativeModule(id) {
this.filename = id + '.js';
this.filename = `${id}.js`;
this.id = id;
this.exports = {};
this.loaded = false;
Expand All @@ -895,10 +895,10 @@
}

if (!NativeModule.exists(id)) {
throw new Error('No such native module ' + id);
throw new Error(`No such native module ${id}`);
}

process.moduleLoadList.push('NativeModule ' + id);
process.moduleLoadList.push(`NativeModule ${id}`);

var nativeModule = new NativeModule(id);

Expand Down

0 comments on commit 92a0d69

Please sign in to comment.