Skip to content

Commit 0a43ad1

Browse files
committedMar 9, 2017
ES2015ify
1 parent 90b1628 commit 0a43ad1

20 files changed

+286
-459
lines changed
 

‎.editorconfig

-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,5 @@ charset = utf-8
77
trim_trailing_whitespace = true
88
insert_final_newline = true
99

10-
[*.md]
11-
trim_trailing_whitespace = false
12-
1310
[Makefile]
1411
indent_style = tab

‎.eslintrc

-121
This file was deleted.

‎.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
* text=auto
2+
*.js text eol=lf

‎.travis.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
sudo: false
22
language: node_js
33
node_js:
4-
- v6
5-
- v5
6-
- v4
4+
- '6'
5+
- '4'
76
before_script:
87
- export NODE_PATH="$NVM_PATH/../node_modules"
98
env:

‎benchmark/env.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
/*global suite, bench */
1+
/* global suite, bench */
22
'use strict';
3-
var yeoman = require('..');
3+
const yeoman = require('..');
44

5-
suite('Environment', function () {
6-
bench('#lookup()', function (done) {
5+
suite('Environment', () => {
6+
bench('#lookup()', done => {
77
yeoman.createEnv().lookup(done);
88
});
99
});

‎gulpfile.js

+20-36
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,34 @@
11
'use strict';
2-
var path = require('path');
3-
var gulp = require('gulp');
4-
var eslint = require('gulp-eslint');
5-
var excludeGitignore = require('gulp-exclude-gitignore');
6-
var mocha = require('gulp-mocha');
7-
var istanbul = require('gulp-istanbul');
8-
var nsp = require('gulp-nsp');
9-
var plumber = require('gulp-plumber');
10-
var coveralls = require('gulp-coveralls');
11-
12-
gulp.task('static', function () {
13-
return gulp.src('**/*.js')
14-
.pipe(excludeGitignore())
15-
.pipe(eslint())
16-
.pipe(eslint.format())
17-
.pipe(eslint.failAfterError());
18-
});
19-
20-
gulp.task('nsp', function (cb) {
2+
const path = require('path');
3+
const gulp = require('gulp');
4+
const mocha = require('gulp-mocha');
5+
const istanbul = require('gulp-istanbul');
6+
const nsp = require('gulp-nsp');
7+
const plumber = require('gulp-plumber');
8+
const coveralls = require('gulp-coveralls');
9+
10+
gulp.task('nsp', cb => {
2111
nsp({package: path.resolve('package.json')}, cb);
2212
});
2313

24-
gulp.task('pre-test', function () {
25-
return gulp.src('lib/**/*.js')
14+
gulp.task('pre-test', () =>
15+
gulp.src('lib/**/*.js')
2616
.pipe(istanbul({
2717
includeUntested: true
2818
}))
29-
.pipe(istanbul.hookRequire());
30-
});
31-
32-
gulp.task('test', ['pre-test'], function (cb) {
33-
var mochaErr;
19+
.pipe(istanbul.hookRequire())
20+
);
3421

22+
gulp.task('test', ['pre-test'], () =>
3523
gulp.src('test/*.js')
3624
.pipe(plumber())
37-
.pipe(mocha({reporter: 'spec'}))
38-
.on('error', function (err) {
39-
mochaErr = err;
40-
})
25+
.pipe(mocha({
26+
reporter: 'spec'
27+
}))
4128
.pipe(istanbul.writeReports())
42-
.on('end', function () {
43-
cb(mochaErr);
44-
});
45-
});
29+
);
4630

47-
gulp.task('coveralls', ['test'], function () {
31+
gulp.task('coveralls', ['test'], () => {
4832
if (!process.env.CI) {
4933
return;
5034
}
@@ -54,4 +38,4 @@ gulp.task('coveralls', ['test'], function () {
5438
});
5539

5640
gulp.task('prepublish', ['nsp']);
57-
gulp.task('default', ['static', 'test', 'coveralls']);
41+
gulp.task('default', ['test', 'coveralls']);

‎lib/adapter.js

+11-14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
'use strict';
2-
3-
var _ = require('lodash');
4-
var inquirer = require('inquirer');
5-
var diff = require('diff');
6-
var chalk = require('chalk');
7-
var logger = require('./util/log');
2+
const _ = require('lodash');
3+
const inquirer = require('inquirer');
4+
const diff = require('diff');
5+
const chalk = require('chalk');
6+
const logger = require('./util/log');
87

98
/**
109
* `TerminalAdapter` is the default implementation of `Adapter`, an abstraction
@@ -14,16 +13,14 @@ var logger = require('./util/log');
1413
*
1514
* @constructor
1615
*/
17-
var TerminalAdapter = module.exports = function TerminalAdapter() {
16+
const TerminalAdapter = module.exports = function TerminalAdapter() {
1817
this.promptModule = inquirer.createPromptModule();
1918
};
2019

2120
TerminalAdapter.prototype._colorDiffAdded = chalk.black.bgGreen;
2221
TerminalAdapter.prototype._colorDiffRemoved = chalk.bgRed;
2322
TerminalAdapter.prototype._colorLines = function colorLines(name, str) {
24-
return str.split('\n').map(function (line) {
25-
return this['_colorDiff' + name](line);
26-
}, this).join('\n');
23+
return str.split('\n').map(line => this[`_colorDiff${name}`](line)).join('\n');
2724
};
2825

2926
/**
@@ -47,7 +44,7 @@ TerminalAdapter.prototype.prompt = function () {};
4744
* @param {string} expected
4845
*/
4946
TerminalAdapter.prototype.diff = function _diff(actual, expected) {
50-
var msg = diff.diffLines(actual, expected).map(function (str) {
47+
let msg = diff.diffLines(actual, expected).map(str => {
5148
if (str.added) {
5249
return this._colorLines('Added', str.value);
5350
}
@@ -57,9 +54,9 @@ TerminalAdapter.prototype.diff = function _diff(actual, expected) {
5754
}
5855

5956
return str.value;
60-
}, this).join('');
57+
}).join('');
6158

62-
// legend
59+
// Legend
6360
msg = '\n' +
6461
this._colorDiffRemoved('removed') +
6562
' ' +
@@ -79,7 +76,7 @@ TerminalAdapter.prototype.diff = function _diff(actual, expected) {
7976
TerminalAdapter.prototype.log = logger();
8077

8178
TerminalAdapter.prototype.prompt = function (questions, cb) {
82-
var promise = this.promptModule(questions);
79+
const promise = this.promptModule(questions);
8380
promise.then(cb || _.noop);
8481
return promise;
8582
};

‎lib/environment.js

+52-74
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
'use strict';
2-
var util = require('util');
3-
var fs = require('fs');
4-
var path = require('path');
5-
var events = require('events');
6-
var chalk = require('chalk');
7-
var _ = require('lodash');
8-
var GroupedQueue = require('grouped-queue');
9-
var escapeStrRe = require('escape-string-regexp');
10-
var untildify = require('untildify');
11-
var memFs = require('mem-fs');
12-
var debug = require('debug')('yeoman:environment');
13-
var Store = require('./store');
14-
var resolver = require('./resolver');
15-
var TerminalAdapter = require('./adapter');
2+
const util = require('util');
3+
const fs = require('fs');
4+
const path = require('path');
5+
const events = require('events');
6+
const chalk = require('chalk');
7+
const _ = require('lodash');
8+
const GroupedQueue = require('grouped-queue');
9+
const escapeStrRe = require('escape-string-regexp');
10+
const untildify = require('untildify');
11+
const memFs = require('mem-fs');
12+
const debug = require('debug')('yeoman:environment');
13+
const Store = require('./store');
14+
const resolver = require('./resolver');
15+
const TerminalAdapter = require('./adapter');
1616

1717
/**
1818
* `Environment` object is responsible of handling the lifecyle and bootstrap
@@ -36,8 +36,7 @@ var TerminalAdapter = require('./adapter');
3636
* implementing this adapter interface. This is how
3737
* you'd interface Yeoman with a GUI or an editor.
3838
*/
39-
40-
var Environment = module.exports = function Environment(args, opts, adapter) {
39+
const Environment = module.exports = function Environment(args, opts, adapter) {
4140
events.EventEmitter.call(this);
4241

4342
args = args || [];
@@ -84,7 +83,6 @@ Environment.queues = [
8483
* @param {Object} err
8584
* @return {Error} err
8685
*/
87-
8886
Environment.prototype.error = function error(err) {
8987
err = err instanceof Error ? err : new Error(err);
9088

@@ -101,11 +99,10 @@ Environment.prototype.error = function error(err) {
10199
*
102100
* @param {String} name
103101
*/
104-
105102
Environment.prototype.help = function help(name) {
106103
name = name || 'init';
107104

108-
var out = [
105+
const out = [
109106
'Usage: :binary: GENERATOR [args] [options]',
110107
'',
111108
'General options:',
@@ -116,11 +113,11 @@ Environment.prototype.help = function help(name) {
116113
''
117114
];
118115

119-
var ns = this.namespaces();
116+
const ns = this.namespaces();
120117

121-
var groups = {};
122-
ns.forEach(function (namespace) {
123-
var base = namespace.split(':')[0];
118+
const groups = {};
119+
ns.forEach(namespace => {
120+
const base = namespace.split(':')[0];
124121

125122
if (!groups[base]) {
126123
groups[base] = [];
@@ -129,15 +126,15 @@ Environment.prototype.help = function help(name) {
129126
groups[base].push(namespace);
130127
});
131128

132-
Object.keys(groups).sort().forEach(function (key) {
133-
var group = groups[key];
129+
Object.keys(groups).sort().forEach(key => {
130+
const group = groups[key];
134131

135132
if (group.length >= 1) {
136133
out.push('', key.charAt(0).toUpperCase() + key.slice(1));
137134
}
138135

139-
groups[key].forEach(function (ns) {
140-
out.push(' ' + ns);
136+
groups[key].forEach(ns => {
137+
out.push(` ${ns}`);
141138
});
142139
});
143140

@@ -152,13 +149,12 @@ Environment.prototype.help = function help(name) {
152149
* @param {String} namespace - Namespace under which register the generator (optional)
153150
* @return {String} namespace - Namespace assigned to the registered generator
154151
*/
155-
156152
Environment.prototype.register = function register(name, namespace) {
157153
if (!_.isString(name)) {
158154
return this.error(new Error('You must provide a generator name to register.'));
159155
}
160156

161-
var modulePath = this.resolveModulePath(name);
157+
const modulePath = this.resolveModulePath(name);
162158
namespace = namespace || this.namespace(modulePath);
163159

164160
if (!namespace) {
@@ -180,7 +176,6 @@ Environment.prototype.register = function register(name, namespace) {
180176
* @param {String} namespace - Namespace under which register the generator
181177
* @return {this}
182178
*/
183-
184179
Environment.prototype.registerStub = function registerStub(Generator, namespace) {
185180
if (!_.isFunction(Generator)) {
186181
return this.error(new Error('You must provide a stub function to register.'));
@@ -199,7 +194,6 @@ Environment.prototype.registerStub = function registerStub(Generator, namespace)
199194
* Returns the list of registered namespace.
200195
* @return {Array}
201196
*/
202-
203197
Environment.prototype.namespaces = function namespaces() {
204198
return this.store.namespaces();
205199
};
@@ -208,7 +202,6 @@ Environment.prototype.namespaces = function namespaces() {
208202
* Returns stored generators meta
209203
* @return {Object}
210204
*/
211-
212205
Environment.prototype.getGeneratorsMeta = function getGeneratorsMeta() {
213206
return this.store.getGeneratorsMeta();
214207
};
@@ -218,7 +211,6 @@ Environment.prototype.getGeneratorsMeta = function getGeneratorsMeta() {
218211
*
219212
* @return {Array}
220213
*/
221-
222214
Environment.prototype.getGeneratorNames = function getGeneratorNames() {
223215
return _.uniq(Object.keys(this.getGeneratorsMeta()).map(Environment.namespaceToName));
224216
};
@@ -233,20 +225,19 @@ Environment.prototype.getGeneratorNames = function getGeneratorNames() {
233225
* @param {String} namespaceOrPath
234226
* @return {Generator|null} - the generator registered under the namespace
235227
*/
236-
237228
Environment.prototype.get = function get(namespaceOrPath) {
238229
// Stop the recursive search if nothing is left
239230
if (!namespaceOrPath) {
240231
return;
241232
}
242233

243-
var namespace = namespaceOrPath;
234+
let namespace = namespaceOrPath;
244235

245236
// Legacy yeoman-generator `#hookFor()` function is passing the generator path as part
246237
// of the namespace. If we find a path delimiter in the namespace, then ignore the
247238
// last part of the namespace.
248-
var parts = namespaceOrPath.split(':');
249-
var maybePath = _.last(parts);
239+
const parts = namespaceOrPath.split(':');
240+
const maybePath = _.last(parts);
250241
if (parts.length > 1 && /[\/\\]/.test(maybePath)) {
251242
parts.pop();
252243

@@ -260,7 +251,7 @@ Environment.prototype.get = function get(namespaceOrPath) {
260251

261252
return this.store.get(namespace) ||
262253
this.store.get(this.alias(namespace)) ||
263-
// namespace is empty if namespaceOrPath contains a win32 absolute path of the form 'C:\path\to\generator'.
254+
// Namespace is empty if namespaceOrPath contains a win32 absolute path of the form 'C:\path\to\generator'.
264255
// for this reason we pass namespaceOrPath to the getByPath function.
265256
this.getByPath(namespaceOrPath);
266257
};
@@ -272,7 +263,7 @@ Environment.prototype.get = function get(namespaceOrPath) {
272263
*/
273264
Environment.prototype.getByPath = function (path) {
274265
if (fs.existsSync(path)) {
275-
var namespace = this.namespace(path);
266+
const namespace = this.namespace(path);
276267
this.register(path, namespace);
277268

278269
return this.get(namespace);
@@ -289,11 +280,10 @@ Environment.prototype.getByPath = function (path) {
289280
* @param {String} namespace
290281
* @param {Object} options
291282
*/
292-
293283
Environment.prototype.create = function create(namespace, options) {
294284
options = options || {};
295285

296-
var Generator = this.get(namespace);
286+
const Generator = this.get(namespace);
297287

298288
if (!_.isFunction(Generator)) {
299289
return this.error(
@@ -321,14 +311,13 @@ Environment.prototype.create = function create(namespace, options) {
321311
* @param {Array|String} options.arguments Arguments to pass the instance
322312
* @param {Object} options.options Options to pass the instance
323313
*/
324-
325314
Environment.prototype.instantiate = function instantiate(Generator, options) {
326315
options = options || {};
327316

328-
var args = options.arguments || options.args || _.clone(this.arguments);
317+
let args = options.arguments || options.args || _.clone(this.arguments);
329318
args = Array.isArray(args) ? args : args.split(' ');
330319

331-
var opts = options.options || _.clone(this.options);
320+
const opts = options.options || _.clone(this.options);
332321

333322
opts.env = this;
334323
opts.resolved = Generator.resolved || 'unknown';
@@ -346,7 +335,6 @@ Environment.prototype.instantiate = function instantiate(Generator, options) {
346335
* @param {Object} options
347336
* @param {Function} done
348337
*/
349-
350338
Environment.prototype.run = function run(args, options, done) {
351339
args = args || this.arguments;
352340

@@ -364,14 +352,14 @@ Environment.prototype.run = function run(args, options, done) {
364352
args = Array.isArray(args) ? args : args.split(' ');
365353
options = options || this.options;
366354

367-
var name = args.shift();
355+
const name = args.shift();
368356
if (!name) {
369357
return this.error(new Error('Must provide at least one argument, the generator namespace to invoke.'));
370358
}
371359

372-
var generator = this.create(name, {
373-
args: args,
374-
options: options
360+
const generator = this.create(name, {
361+
args,
362+
options
375363
});
376364

377365
if (generator instanceof Error) {
@@ -404,36 +392,35 @@ Environment.prototype.run = function run(args, options, done) {
404392
*
405393
* @param {String} filepath
406394
*/
407-
408395
Environment.prototype.namespace = function namespace(filepath) {
409396
if (!filepath) {
410397
throw new Error('Missing namespace');
411398
}
412399

413-
// cleanup extension and normalize path for differents OS
414-
var ns = path.normalize(filepath.replace(new RegExp(escapeStrRe(path.extname(filepath)) + '$'), ''));
400+
// Cleanup extension and normalize path for differents OS
401+
let ns = path.normalize(filepath.replace(new RegExp(escapeStrRe(path.extname(filepath)) + '$'), ''));
415402

416403
// Sort lookups by length so biggest are removed first
417-
var lookups = _(this.lookups.concat(['..'])).map(path.normalize).sortBy('length').value().reverse();
404+
const lookups = _(this.lookups.concat(['..'])).map(path.normalize).sortBy('length').value().reverse();
418405

419-
// if `ns` contains a lookup dir in its path, remove it.
420-
ns = lookups.reduce(function (ns, lookup) {
421-
// only match full directory (begin with leading slash or start of input, end with trailing slash)
406+
// If `ns` contains a lookup dir in its path, remove it.
407+
ns = lookups.reduce((ns, lookup) => {
408+
// Only match full directory (begin with leading slash or start of input, end with trailing slash)
422409
lookup = new RegExp('(?:\\\\|/|^)' + escapeStrRe(lookup) + '(?=\\\\|/)', 'g');
423410
return ns.replace(lookup, '');
424411
}, ns);
425412

426-
var folders = ns.split(path.sep);
427-
var scope = _.findLast(folders, function (folder) {
413+
const folders = ns.split(path.sep);
414+
const scope = _.findLast(folders, folder => {
428415
return folder.indexOf('@') === 0;
429416
});
430417

431-
// cleanup `ns` from unwanted parts and then normalize slashes to `:`
418+
// Cleanup `ns` from unwanted parts and then normalize slashes to `:`
432419
ns = ns
433-
.replace(/(.*generator-)/, '') // remove before `generator-`
434-
.replace(/[\/\\](index|main)$/, '') // remove `/index` or `/main`
435-
.replace(/^[\/\\]+/, '') // remove leading `/`
436-
.replace(/[\/\\]+/g, ':'); // replace slashes by `:`
420+
.replace(/(.*generator-)/, '') // Remove before `generator-`
421+
.replace(/[\/\\](index|main)$/, '') // Remove `/index` or `/main`
422+
.replace(/^[\/\\]+/, '') // Remove leading `/`
423+
.replace(/[\/\\]+/g, ':'); // Replace slashes by `:`
437424

438425
if (scope) {
439426
ns = scope + '/' + ns;
@@ -449,7 +436,6 @@ Environment.prototype.namespace = function namespace(filepath) {
449436
* @param {String} moduleId - Filepath or module name
450437
* @return {String} - The resolved path leading to the module
451438
*/
452-
453439
Environment.prototype.resolveModulePath = function resolveModulePath(moduleId) {
454440
if (moduleId[0] === '.') {
455441
moduleId = path.resolve(moduleId);
@@ -467,7 +453,6 @@ Environment.prototype.resolveModulePath = function resolveModulePath(moduleId) {
467453
* @param {Environment} env
468454
* @return {Environment} The updated env
469455
*/
470-
471456
Environment.enforceUpdate = function (env) {
472457
if (!env.adapter) {
473458
env.adapter = new TerminalAdapter();
@@ -501,25 +486,18 @@ Environment.enforceUpdate = function (env) {
501486
*
502487
* @return {Environment} a new Environment instance
503488
*/
504-
505-
Environment.createEnv = function (args, opts, adapter) {
506-
return new Environment(args, opts, adapter);
507-
};
489+
Environment.createEnv = (args, opts, adapter) => new Environment(args, opts, adapter);
508490

509491
/**
510492
* Convert a generators namespace to its name
511493
*
512494
* @param {String} namespace
513495
* @return {String}
514496
*/
515-
516-
Environment.namespaceToName = function (namespace) {
517-
return namespace.split(':')[0];
518-
};
497+
Environment.namespaceToName = namespace => namespace.split(':')[0];
519498

520499
/**
521500
* Expose the utilities on the module
522501
* @see {@link env/util}
523502
*/
524-
525503
Environment.util = require('./util/util');

‎lib/resolver.js

+38-42
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
'use strict';
2-
var path = require('path');
3-
var fs = require('fs');
4-
var _ = require('lodash');
5-
var globby = require('globby');
6-
var debug = require('debug')('yeoman:environment');
2+
const path = require('path');
3+
const fs = require('fs');
4+
const _ = require('lodash');
5+
const globby = require('globby');
6+
const debug = require('debug')('yeoman:environment');
77

8-
var win32 = process.platform === 'win32';
8+
const win32 = process.platform === 'win32';
99

1010
/**
1111
* @mixin
1212
* @alias env/resolver
1313
*/
14-
var resolver = module.exports;
14+
const resolver = module.exports;
1515

1616
/**
1717
* Search for generators and their sub generators.
@@ -29,24 +29,23 @@ var resolver = module.exports;
2929
* @param {function} cb - Callback called once the lookup is done. Take err as first
3030
* parameter.
3131
*/
32-
3332
resolver.lookup = function (cb) {
34-
var generatorsModules = this.findGeneratorsIn(this.getNpmPaths());
35-
var patterns = [];
33+
const generatorsModules = this.findGeneratorsIn(this.getNpmPaths());
34+
const patterns = [];
3635

37-
this.lookups.forEach(function (lookup) {
38-
generatorsModules.forEach(function (modulePath) {
36+
for (const lookup of this.lookups) {
37+
for (const modulePath of generatorsModules) {
3938
patterns.push(path.join(modulePath, lookup));
40-
});
41-
});
39+
}
40+
}
4241

43-
patterns.forEach(function (pattern) {
44-
globby.sync('*/index.js', { cwd: pattern }).forEach(function (filename) {
42+
for (const pattern of patterns) {
43+
for (const filename of globby.sync('*/index.js', {cwd: pattern})) {
4544
this._tryRegistering(path.join(pattern, filename));
46-
}, this);
47-
}, this);
45+
}
46+
}
4847

49-
if (_.isFunction(cb)) {
48+
if (typeof cb === 'function') {
5049
return cb(null);
5150
}
5251
};
@@ -59,22 +58,21 @@ resolver.lookup = function (cb) {
5958
* @param {Array} List of search paths
6059
* @return {Array} List of the generator modules path
6160
*/
62-
6361
resolver.findGeneratorsIn = function (searchPaths) {
64-
var modules = [];
62+
let modules = [];
6563

66-
searchPaths.forEach(function (root) {
64+
for (const root of searchPaths) {
6765
if (!root) {
6866
return;
6967
}
7068

7169
modules = globby.sync([
7270
'generator-*',
7371
'@*/generator-*'
74-
], { cwd: root }).map(function (match) {
75-
return path.join(root, match);
76-
}).concat(modules);
77-
});
72+
], {cwd: root})
73+
.map(match => path.join(root, match))
74+
.concat(modules);
75+
}
7876

7977
return modules;
8078
};
@@ -84,10 +82,9 @@ resolver.findGeneratorsIn = function (searchPaths) {
8482
* @private
8583
* @param {String} generatorReference A generator reference, usually a file path.
8684
*/
87-
8885
resolver._tryRegistering = function (generatorReference) {
89-
var namespace;
90-
var realPath = fs.realpathSync(generatorReference);
86+
let namespace;
87+
const realPath = fs.realpathSync(generatorReference);
9188

9289
try {
9390
debug('found %s, trying to register', generatorReference);
@@ -97,8 +94,8 @@ resolver._tryRegistering = function (generatorReference) {
9794
}
9895

9996
this.register(realPath, namespace);
100-
} catch (e) {
101-
console.error('Unable to register %s (Error: %s)', generatorReference, e.message);
97+
} catch (err) {
98+
console.error('Unable to register %s (Error: %s)', generatorReference, err.message);
10299
}
103100
};
104101

@@ -107,7 +104,7 @@ resolver._tryRegistering = function (generatorReference) {
107104
* @return {Array} lookup paths
108105
*/
109106
resolver.getNpmPaths = function () {
110-
var paths = [];
107+
let paths = [];
111108

112109
// Add NVM prefix directory
113110
if (process.env.NVM_PATH) {
@@ -126,7 +123,7 @@ resolver.getNpmPaths = function () {
126123
paths.push(path.join(__dirname, '../../../..'));
127124
paths.push(path.join(__dirname, '../..'));
128125

129-
// adds support for generator resolving when yeoman-generator has been linked
126+
// Adds support for generator resolving when yeoman-generator has been linked
130127
if (process.argv[1]) {
131128
paths.push(path.join(path.dirname(process.argv[1]), '../..'));
132129
}
@@ -140,11 +137,11 @@ resolver.getNpmPaths = function () {
140137
}
141138

142139
// Walk up the CWD and add `node_modules/` folder lookup on each level
143-
process.cwd().split(path.sep).forEach(function (part, i, parts) {
144-
var lookup = path.join.apply(path, parts.slice(0, i + 1).concat(['node_modules']));
140+
process.cwd().split(path.sep).forEach((part, i, parts) => {
141+
let lookup = path.join.apply(path, parts.slice(0, i + 1).concat(['node_modules']));
145142

146143
if (!win32) {
147-
lookup = '/' + lookup;
144+
lookup = `/${lookup}`;
148145
}
149146

150147
paths.push(lookup);
@@ -182,19 +179,18 @@ resolver.getNpmPaths = function () {
182179
* env.alias('foo');
183180
* // => generator-foo:all
184181
*/
185-
186-
resolver.alias = function alias(match, value) {
182+
resolver.alias = function (match, value) {
187183
if (match && value) {
188184
this.aliases.push({
189-
match: match instanceof RegExp ? match : new RegExp('^' + match + '$'),
190-
value: value
185+
match: match instanceof RegExp ? match : new RegExp(`^${match}$`),
186+
value
191187
});
192188
return this;
193189
}
194190

195-
var aliases = this.aliases.slice(0).reverse();
191+
const aliases = this.aliases.slice(0).reverse();
196192

197-
return aliases.reduce(function (res, alias) {
193+
return aliases.reduce((res, alias) => {
198194
if (!alias.match.test(res)) {
199195
return res;
200196
}

‎lib/store.js

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
'use strict';
2-
var _ = require('lodash');
32

43
/**
54
* The Generator store
@@ -8,8 +7,7 @@ var _ = require('lodash');
87
* @constructor
98
* @private
109
*/
11-
12-
var Store = module.exports = function Store() {
10+
const Store = module.exports = function Store() {
1311
this._generators = {};
1412
this._meta = {};
1513
};
@@ -19,9 +17,8 @@ var Store = module.exports = function Store() {
1917
* @param {String} namespace - The key under which the generator can be retrieved
2018
* @param {String|Function} generator - A generator module or a module path
2119
*/
22-
2320
Store.prototype.add = function add(namespace, generator) {
24-
if (_.isString(generator)) {
21+
if (typeof generator === 'string') {
2522
this._storeAsPath(namespace, generator);
2623
return;
2724
}
@@ -32,12 +29,12 @@ Store.prototype.add = function add(namespace, generator) {
3229
Store.prototype._storeAsPath = function _storeAsPath(namespace, path) {
3330
this._meta[namespace] = {
3431
resolved: path,
35-
namespace: namespace
32+
namespace
3633
};
3734

3835
Object.defineProperty(this._generators, namespace, {
39-
get: function () {
40-
var Generator = require(path);
36+
get() {
37+
const Generator = require(path);
4138
return Generator;
4239
},
4340
enumerable: true,
@@ -48,7 +45,7 @@ Store.prototype._storeAsPath = function _storeAsPath(namespace, path) {
4845
Store.prototype._storeAsModule = function _storeAsModule(namespace, Generator) {
4946
this._meta[namespace] = {
5047
resolved: 'unknown',
51-
namespace: namespace
48+
namespace
5249
};
5350

5451
this._generators[namespace] = Generator;
@@ -61,13 +58,13 @@ Store.prototype._storeAsModule = function _storeAsModule(namespace, Generator) {
6158
*/
6259

6360
Store.prototype.get = function get(namespace) {
64-
var Generator = this._generators[namespace];
61+
const Generator = this._generators[namespace];
6562

6663
if (!Generator) {
6764
return;
6865
}
6966

70-
return _.extend(Generator, this._meta[namespace]);
67+
return Object.assign(Generator, this._meta[namespace]);
7168
};
7269

7370
/**

‎lib/util/log.js

+35-33
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
/** @module env/log */
22
'use strict';
3-
4-
var util = require('util');
5-
var events = require('events');
6-
var _ = require('lodash');
7-
var table = require('text-table');
8-
var chalk = require('chalk');
9-
var logSymbols = require('log-symbols');
10-
11-
// padding step
12-
var step = ' ';
13-
var padding = ' ';
14-
15-
// color -> status mappings
16-
var colors = {
3+
const util = require('util');
4+
const EventEmitter = require('events');
5+
const _ = require('lodash');
6+
const table = require('text-table');
7+
const chalk = require('chalk');
8+
const logSymbols = require('log-symbols');
9+
10+
// Padding step
11+
const step = ' ';
12+
let padding = ' ';
13+
14+
// Color -> status mappings
15+
const colors = {
1716
skip: 'yellow',
1817
force: 'yellow',
1918
create: 'green',
@@ -24,16 +23,16 @@ var colors = {
2423
};
2524

2625
function pad(status) {
27-
var max = 'identical'.length;
28-
var delta = max - status.length;
29-
return delta ? new Array(delta + 1).join(' ') + status : status;
26+
const max = 'identical'.length;
27+
const delta = max - status.length;
28+
return delta ? ' '.repeat(delta) + status : status;
3029
}
3130

32-
// borrowed from https://github.com/mikeal/logref/blob/master/main.js#L6-15
31+
// Borrowed from https://github.com/mikeal/logref/blob/master/main.js#L6-15
3332
function formatter(msg, ctx) {
3433
while (msg.indexOf('%') !== -1) {
35-
var start = msg.indexOf('%');
36-
var end = msg.indexOf(' ', start);
34+
const start = msg.indexOf('%');
35+
let end = msg.indexOf(' ', start);
3736

3837
if (end === -1) {
3938
end = msg.length;
@@ -45,7 +44,7 @@ function formatter(msg, ctx) {
4544
return msg;
4645
}
4746

48-
module.exports = function logger() {
47+
module.exports = () => {
4948
// `this.log` is a [logref](https://github.com/mikeal/logref)
5049
// compatible logger, with an enhanced API.
5150
//
@@ -75,7 +74,7 @@ module.exports = function logger() {
7574
return log;
7675
}
7776

78-
_.extend(log, events.EventEmitter.prototype);
77+
_.extend(log, EventEmitter.prototype);
7978

8079
// A simple write method, with formatted message.
8180
//
@@ -105,15 +104,17 @@ module.exports = function logger() {
105104
return this;
106105
};
107106

108-
log.on('up', function () {
109-
padding = padding + step;
107+
log.on('up', () => {
108+
padding += step;
110109
});
111110

112-
log.on('down', function () {
111+
log.on('down', () => {
113112
padding = padding.replace(step, '');
114113
});
115114

116-
Object.keys(colors).forEach(function (status) {
115+
// eslint-disable no-loop-func
116+
// TODO: Fix this ESLint warning
117+
for (const status of Object.keys(colors)) {
117118
// Each predefined status has its logging method utility, handling
118119
// status color and padding before the usual `.write()`
119120
//
@@ -139,12 +140,13 @@ module.exports = function logger() {
139140
//
140141
// Returns the logger
141142
log[status] = function () {
142-
var color = colors[status];
143+
const color = colors[status];
143144
this.write(chalk[color](pad(status))).write(padding);
144145
this.write(util.format.apply(util, arguments) + '\n');
145146
return this;
146147
};
147-
});
148+
}
149+
// eslint-enable no-loop-func
148150

149151
// A basic wrapper around `cli-table` package, resetting any single
150152
// char to empty strings, this is used for aligning options and
@@ -154,15 +156,15 @@ module.exports = function logger() {
154156
// table.
155157
//
156158
// Returns the table reprensetation
157-
log.table = function (opts) {
158-
var tableData = [];
159+
log.table = opts => {
160+
const tableData = [];
159161

160-
opts = Array.isArray(opts) ? { rows: opts } : opts;
162+
opts = Array.isArray(opts) ? {rows: opts} : opts;
161163
opts.rows = opts.rows || [];
162164

163-
opts.rows.forEach(function (row) {
165+
for (const row of opts.rows) {
164166
tableData.push(row);
165-
});
167+
}
166168

167169
return table(tableData);
168170
};

‎lib/util/util.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/** @module env/util */
22
'use strict';
3-
4-
var GroupedQueue = require('grouped-queue');
3+
const GroupedQueue = require('grouped-queue');
54

65
/**
76
* Create a "sloppy" copy of an initial Environment object. The focus of this method is on
@@ -13,11 +12,10 @@ var GroupedQueue = require('grouped-queue');
1312
* @param {Environment} initialEnv - an Environment instance
1413
* @return {Environment} sloppy copy of the initial Environment
1514
*/
16-
17-
exports.duplicateEnv = function (initialEnv) {
18-
var queues = require('../environment').queues;
15+
exports.duplicateEnv = initialEnv => {
16+
const queues = require('../environment').queues;
1917
// Hack: create a clone of the environment with a new instance of runLoop
20-
var env = Object.create(initialEnv);
18+
const env = Object.create(initialEnv);
2119
env.runLoop = new GroupedQueue(queues);
2220
return env;
2321
};

‎package.json

+8-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"license": "BSD-2-Clause",
2525
"repository": "yeoman/environment",
2626
"scripts": {
27-
"test": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
27+
"test": "gulp",
2828
"doc": "jsdoc -c ./jsdoc.json ./readme.md",
2929
"benchmark": "matcha benchmark/**",
3030
"prepublish": "gulp prepublish"
@@ -47,10 +47,7 @@
4747
"coveralls": "^2.11.6",
4848
"gulp": "^3.6.0",
4949
"gulp-coveralls": "^0.1.0",
50-
"gulp-eslint": "^3.0.1",
51-
"gulp-exclude-gitignore": "^1.0.0",
5250
"gulp-istanbul": "^1.1.1",
53-
"gulp-jscs": "^4.0.0",
5451
"gulp-mocha": "^3.0.1",
5552
"gulp-nsp": "^2.1.0",
5653
"gulp-plumber": "^1.0.0",
@@ -62,5 +59,12 @@
6259
"sinon": "^1.9.1",
6360
"yeoman-assert": "^3.0.0",
6461
"yeoman-generator": "^1.1.0"
62+
},
63+
"xo": {
64+
"space": true,
65+
"envs": [
66+
"node",
67+
"mocha"
68+
]
6569
}
6670
}

‎readme.md

+9-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
It provides a high-level API to discover, create and run generators, as well as further tuning of where and how a generator is resolved.
88

9+
910
## Install
1011

1112
```
@@ -15,16 +16,16 @@ $ npm install --save yeoman-environment
1516

1617
## Usage
1718

18-
Full documentation available at http://yeoman.io/authoring/integrating-yeoman.html
19+
Full documentation available [here](http://yeoman.io/authoring/integrating-yeoman.html).
1920

2021
```js
21-
var yeoman = require('yeoman-environment');
22-
var env = yeoman.createEnv();
22+
const yeoman = require('yeoman-environment');
23+
const env = yeoman.createEnv();
2324

24-
// The #lookup() method will search the user computer for installed generators.
25-
// The search if done from the current working directory.
26-
env.lookup(function () {
27-
env.run('angular', {'skip-install': true}, function (err) {
25+
// The #lookup() method will search the user computer for installed generators
26+
// The search if done from the current working directory
27+
env.lookup(() => {
28+
env.run('angular', {'skip-install': true}, err => {
2829
console.log('done');
2930
});
3031
});
@@ -35,4 +36,4 @@ For advance usage, see [our API documentation](http://yeoman.github.io/environme
3536

3637
## License
3738

38-
BSD © Yeoman
39+
BSD-2-Clause © Yeoman

‎test/adapter.js

+28-30
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
'use strict';
2-
var assert = require('yeoman-assert');
3-
var _ = require('lodash');
4-
var inquirer = require('inquirer');
5-
var sinon = require('sinon');
6-
var logSymbols = require('log-symbols');
7-
var TerminalAdapter = require('../lib/adapter');
8-
9-
describe('TerminalAdapter', function () {
2+
const assert = require('yeoman-assert');
3+
const inquirer = require('inquirer');
4+
const sinon = require('sinon');
5+
const logSymbols = require('log-symbols');
6+
const TerminalAdapter = require('../lib/adapter');
7+
8+
describe('TerminalAdapter', () => {
109
beforeEach(function () {
1110
this.adapter = new TerminalAdapter();
1211
});
1312

14-
describe('#prompt()', function () {
13+
describe('#prompt()', () => {
1514
beforeEach(function () {
1615
this.sandbox = sinon.sandbox.create();
1716
this.fakePromise = {then: sinon.spy()};
@@ -25,38 +24,38 @@ describe('TerminalAdapter', function () {
2524
});
2625

2726
it('pass its arguments to inquirer', function () {
28-
var questions = [];
29-
var func = function () {};
30-
var ret = this.adapter.prompt(questions, func);
27+
const questions = [];
28+
const func = () => {};
29+
const ret = this.adapter.prompt(questions, func);
3130
sinon.assert.calledWith(this.stub, questions);
3231
sinon.assert.calledWith(this.fakePromise.then, func);
3332
assert.equal(ret, this.fakePromise);
3433
});
3534
});
3635

37-
describe('#diff()', function () {
36+
describe('#diff()', () => {
3837
it('returns properly colored diffs', function () {
39-
var diff = this.adapter.diff('var', 'let');
40-
assert.textEqual(diff, '\n\u001b[41mremoved\u001b[49m \u001b[30m\u001b[42madded\u001b[49m\u001b[39m\n\n\u001b[41mvar\u001b[49m\u001b[30m\u001b[42mlet\u001b[49m\u001b[39m\n');
38+
const diff = this.adapter.diff('var', 'let');
39+
assert.textEqual(diff, '\n\u001B[41mremoved\u001B[49m \u001B[30m\u001B[42madded\u001B[49m\u001B[39m\n\n\u001B[41mvar\u001B[49m\u001B[30m\u001B[42mlet\u001B[49m\u001B[39m\n');
4140
});
4241
});
4342

44-
describe('#log()', function () {
45-
var logMessage;
46-
var stderrWriteBackup = process.stderr.write;
43+
describe('#log()', () => {
44+
let logMessage;
45+
const stderrWriteBackup = process.stderr.write;
4746

4847
beforeEach(function () {
4948
this.spyerror = sinon.spy(console, 'error');
5049

5150
logMessage = '';
52-
process.stderr.write = (function () {
53-
return function (str) {
51+
process.stderr.write = (() => {
52+
return str => {
5453
logMessage = str;
5554
};
56-
}(process.stderr.write));
55+
})(process.stderr.write);
5756
});
5857

59-
afterEach(function () {
58+
afterEach(() => {
6059
console.error.restore();
6160
process.stderr.write = stderrWriteBackup;
6261
});
@@ -90,7 +89,7 @@ describe('TerminalAdapter', function () {
9089
});
9190

9291
it('#write() objects', function () {
93-
var outputObject = {
92+
const outputObject = {
9493
something: 72,
9594
another: 12
9695
};
@@ -99,20 +98,19 @@ describe('TerminalAdapter', function () {
9998
assert(this.spyerror.withArgs(outputObject).calledOnce);
10099
assert.equal(logMessage, '{ something: 72, another: 12 }\n');
101100
});
102-
103101
});
104102

105-
describe('#log', function () {
103+
describe('#log', () => {
106104
beforeEach(function () {
107105
this.spylog = sinon.spy(process.stderr, 'write');
108106
});
109107

110-
afterEach(function () {
108+
afterEach(() => {
111109
process.stderr.write.restore();
112110
});
113111

114112
it('#write() pass strings as they are', function () {
115-
var testString = 'dummy';
113+
const testString = 'dummy';
116114
this.adapter.log.write(testString);
117115
assert(this.spylog.withArgs(testString).calledOnce);
118116
});
@@ -130,15 +128,15 @@ describe('TerminalAdapter', function () {
130128

131129
it('#ok() adds a green "✔ " at the beginning and \\n at the end', function () {
132130
this.adapter.log.ok('dummy');
133-
assert(this.spylog.withArgs(logSymbols.success + ' dummy\n').calledOnce);
131+
assert(this.spylog.withArgs(`${logSymbols.success} dummy\n`).calledOnce);
134132
});
135133

136134
it('#error() adds a green "✗ " at the beginning and \\n at the end', function () {
137135
this.adapter.log.error('dummy');
138-
assert(this.spylog.withArgs(logSymbols.error + ' dummy\n').calledOnce);
136+
assert(this.spylog.withArgs(`${logSymbols.error} dummy\n`).calledOnce);
139137
});
140138

141-
describe('statuses', function () {
139+
describe('statuses', () => {
142140
it('#skip()');
143141
it('#force()');
144142
it('#create()');

‎test/environment.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
/*global it, describe, before, beforeEach, afterEach */
2-
/*jshint scripturl: true */
31
'use strict';
4-
var events = require('events');
5-
var fs = require('fs');
6-
var path = require('path');
7-
var util = require('util');
8-
var sinon = require('sinon');
9-
var Generator = require('yeoman-generator');
10-
var assert = require('yeoman-assert');
11-
var TerminalAdapter = require('../lib/adapter');
12-
var Environment = require('../lib/environment');
2+
const events = require('events');
3+
const fs = require('fs');
4+
const path = require('path');
5+
const util = require('util');
6+
const sinon = require('sinon');
7+
const Generator = require('yeoman-generator');
8+
const assert = require('yeoman-assert');
9+
const TerminalAdapter = require('../lib/adapter');
10+
const Environment = require('../lib/environment');
1311

1412
describe('Environment', function () {
1513
beforeEach(function () {

‎test/fixtures/generator-simple/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = function(args, options) {
1+
module.exports = (args, options) => {
22
console.log('Executing generator with', args, options);
33
};
44

‎test/resolver.js

+38-40
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
'use strict';
2-
var fs = require('fs');
3-
var path = require('path');
4-
var assert = require('assert');
5-
var shell = require('shelljs');
6-
var Environment = require('../lib/environment');
2+
const fs = require('fs');
3+
const path = require('path');
4+
const assert = require('assert');
5+
const shell = require('shelljs');
6+
const Environment = require('../lib/environment');
77

8-
var globalLookupTest = process.env.NODE_PATH ? it : xit;
8+
const globalLookupTest = process.env.NODE_PATH ? it : xit;
99

1010
describe('Environment Resolver', function () {
1111
this.timeout(100000);
1212

13-
describe('#lookup()', function () {
14-
var scopedFolder = path.resolve('./node_modules/@dummyscope');
15-
var scopedGenerator = path.join(scopedFolder, 'generator-scoped');
13+
describe('#lookup()', () => {
14+
const scopedFolder = path.resolve('node_modules/@dummyscope');
15+
const scopedGenerator = path.join(scopedFolder, 'generator-scoped');
1616

1717
before(function () {
1818
this.projectRoot = path.join(__dirname, 'fixtures/lookup-project');
1919
process.chdir(this.projectRoot);
20-
shell.exec('npm install', { silent: true });
21-
shell.exec('npm install generator-jquery', { silent: true });
22-
shell.exec('npm install -g generator-dummytest generator-dummy', { silent: true });
20+
shell.exec('npm install', {silent: true});
21+
shell.exec('npm install generator-jquery', {silent: true});
22+
shell.exec('npm install -g generator-dummytest generator-dummy', {silent: true});
2323

2424
fs.symlinkSync(
25-
path.resolve('../generator-extend'),
26-
path.resolve('./node_modules/generator-extend'),
27-
'dir'
25+
path.resolve('../generator-extend'),
26+
path.resolve('node_modules/generator-extend'),
27+
'dir'
2828
);
2929

3030
if (!fs.existsSync(scopedFolder)) {
@@ -33,15 +33,15 @@ describe('Environment Resolver', function () {
3333

3434
if (!fs.existsSync(scopedGenerator)) {
3535
fs.symlinkSync(
36-
path.resolve('../generator-scoped'),
37-
scopedGenerator,
38-
'dir'
36+
path.resolve('../generator-scoped'),
37+
scopedGenerator,
38+
'dir'
3939
);
4040
}
4141
});
4242

4343
after(function () {
44-
fs.unlinkSync(path.join(this.projectRoot, './node_modules/generator-extend'));
44+
fs.unlinkSync(path.join(this.projectRoot, 'node_modules/generator-extend'));
4545
fs.unlinkSync(scopedGenerator);
4646
fs.rmdirSync(scopedFolder);
4747
process.chdir(__dirname);
@@ -67,8 +67,7 @@ describe('Environment Resolver', function () {
6767
});
6868

6969
if (!process.env.NODE_PATH) {
70-
console.log('Skipping tests for global generators. Please setup `NODE_PATH` ' +
71-
'environment variable to run it.');
70+
console.log('Skipping tests for global generators. Please setup `NODE_PATH` environment variable to run it.');
7271
}
7372

7473
it('local generators prioritized over global', function () {
@@ -84,11 +83,11 @@ describe('Environment Resolver', function () {
8483
assert.ok(this.env.get('extend:support'));
8584
});
8685

87-
describe('when there\'s ancestor node_modules/ folder', function () {
86+
describe('when there\'s ancestor node_modules/ folder', () => {
8887
before(function () {
8988
this.projectSubRoot = path.join(this.projectRoot, 'subdir');
9089
process.chdir(this.projectSubRoot);
91-
shell.exec('npm install', { silent: true });
90+
shell.exec('npm install', {silent: true});
9291
});
9392

9493
beforeEach(function () {
@@ -107,7 +106,7 @@ describe('Environment Resolver', function () {
107106
});
108107
});
109108

110-
describe('#getNpmPaths()', function () {
109+
describe('#getNpmPaths()', () => {
111110
beforeEach(function () {
112111
this.NODE_PATH = process.env.NODE_PATH;
113112
this.bestBet = path.join(__dirname, '../../../..');
@@ -119,17 +118,17 @@ describe('Environment Resolver', function () {
119118
process.env.NODE_PATH = this.NODE_PATH;
120119
});
121120

122-
describe('with NODE_PATH', function () {
123-
beforeEach(function () {
121+
describe('with NODE_PATH', () => {
122+
beforeEach(() => {
124123
process.env.NODE_PATH = '/some/dummy/path';
125124
});
126125

127-
afterEach(function () {
126+
afterEach(() => {
128127
delete process.env.NODE_PATH;
129128
});
130129

131130
it('walk up the CWD lookups dir', function () {
132-
var paths = this.env.getNpmPaths();
131+
const paths = this.env.getNpmPaths();
133132
assert.equal(paths[0], path.join(process.cwd(), 'node_modules'));
134133
assert.equal(paths[1], path.join(process.cwd(), '../node_modules'));
135134
});
@@ -139,15 +138,15 @@ describe('Environment Resolver', function () {
139138
});
140139
});
141140

142-
describe('without NODE_PATH', function () {
143-
beforeEach(function () {
141+
describe('without NODE_PATH', () => {
142+
beforeEach(() => {
144143
delete process.env.NODE_PATH;
145144
});
146145

147146
it('walk up the CWD lookups dir', function () {
148-
var paths = this.env.getNpmPaths();
147+
const paths = this.env.getNpmPaths();
149148
assert.equal(paths[0], path.join(process.cwd(), 'node_modules'));
150-
var prevdir = process.cwd().split(path.sep).slice(0, -1).join(path.sep);
149+
const prevdir = process.cwd().split(path.sep).slice(0, -1).join(path.sep);
151150
assert.equal(paths[1], path.join(prevdir, 'node_modules'));
152151
});
153152

@@ -165,17 +164,17 @@ describe('Environment Resolver', function () {
165164
});
166165
});
167166

168-
describe('with NVM_PATH', function () {
169-
beforeEach(function () {
167+
describe('with NVM_PATH', () => {
168+
beforeEach(() => {
170169
process.env.NVM_PATH = '/some/dummy/path';
171170
});
172171

173-
afterEach(function () {
172+
afterEach(() => {
174173
delete process.env.NVM_PATH;
175174
});
176175

177176
it('walk up the CWD lookups dir', function () {
178-
var paths = this.env.getNpmPaths();
177+
const paths = this.env.getNpmPaths();
179178
assert.equal(paths[0], path.join(process.cwd(), 'node_modules'));
180179
assert.equal(paths[1], path.join(process.cwd(), '../node_modules'));
181180
});
@@ -185,13 +184,13 @@ describe('Environment Resolver', function () {
185184
});
186185
});
187186

188-
describe('without NVM_PATH', function () {
189-
beforeEach(function () {
187+
describe('without NVM_PATH', () => {
188+
beforeEach(() => {
190189
delete process.env.NVM_PATH;
191190
});
192191

193192
it('walk up the CWD lookups dir', function () {
194-
var paths = this.env.getNpmPaths();
193+
const paths = this.env.getNpmPaths();
195194
assert.equal(paths[0], path.join(process.cwd(), 'node_modules'));
196195
assert.equal(paths[1], path.join(process.cwd(), '../node_modules'));
197196
});
@@ -201,6 +200,5 @@ describe('Environment Resolver', function () {
201200
assert(this.env.getNpmPaths().indexOf(this.bestBet2) >= 0);
202201
});
203202
});
204-
205203
});
206204
});

‎test/store.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
'use strict';
2-
var assert = require('assert');
3-
var path = require('path');
4-
var Store = require('../lib/store');
2+
const assert = require('assert');
3+
const path = require('path');
4+
const Store = require('../lib/store');
55

6-
describe('Store', function () {
6+
describe('Store', () => {
77
beforeEach(function () {
88
this.store = new Store();
99
});
1010

11-
describe('#add() / #get()', function () {
11+
describe('#add() / #get()', () => {
1212
beforeEach(function () {
1313
this.modulePath = path.join(__dirname, 'fixtures/generator-mocha');
1414
this.module = require(this.modulePath);
1515
});
1616

17-
describe('storing as module', function () {
17+
describe('storing as module', () => {
1818
beforeEach(function () {
1919
this.store.add('foo:module', this.module);
2020
this.outcome = this.store.get('foo:module');
@@ -33,7 +33,7 @@ describe('Store', function () {
3333
});
3434
});
3535

36-
describe('storing as module path', function () {
36+
describe('storing as module path', () => {
3737
beforeEach(function () {
3838
this.store.add('foo:path', this.modulePath);
3939
this.outcome = this.store.get('foo:path');
@@ -51,7 +51,7 @@ describe('Store', function () {
5151
});
5252
});
5353

54-
describe('#namespaces()', function () {
54+
describe('#namespaces()', () => {
5555
beforeEach(function () {
5656
this.store.add('foo', {});
5757
this.store.add('lab', {});

‎test/util.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
'use strict';
2-
var assert = require('assert');
3-
var util = require('../lib/util/util');
4-
var Env = require('../');
2+
const assert = require('assert');
3+
const util = require('../lib/util/util');
4+
const Env = require('..');
55

6-
describe('util', function () {
7-
it('is exposed on the Environment object', function () {
6+
describe('util', () => {
7+
it('is exposed on the Environment object', () => {
88
assert.equal(Env.util, util);
99
});
1010

11-
describe('.duplicateEnv()', function () {
12-
it('copy environment', function () {
13-
var env = new Env();
14-
var clone = util.duplicateEnv(env);
15-
assert(env.isPrototypeOf(clone));
11+
describe('.duplicateEnv()', () => {
12+
it('copy environment', () => {
13+
const env = new Env();
14+
const clone = util.duplicateEnv(env);
15+
assert(Object.prototype.isPrototypeOf.call(env, clone));
1616
assert.notEqual(clone.runLoop, env.runLoop);
1717
});
1818
});

0 commit comments

Comments
 (0)
Please sign in to comment.