Skip to content

Commit dab9337

Browse files
committedJun 24, 2018
Require Node.js 6
Closes #581 Closes #582
1 parent 479250a commit dab9337

17 files changed

+38
-37
lines changed
 

‎.editorconfig

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ root = true
33
[*]
44
indent_style = space
55
indent_size = 2
6+
end_of_line = lf
67
charset = utf-8
78
trim_trailing_whitespace = true
89
insert_final_newline = true

‎.gitattributes

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

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
2+
yarn.lock
23
coverage

‎.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
sudo: false
21
language: node_js
32
node_js:
3+
- '10'
4+
- '8'
45
- '6'
5-
- '4'

‎lib/cli.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ const cli = gens.map(gen => {
3232

3333
// Add un-camelized options too, for legacy
3434
// TODO: Remove some time in the future when generators have upgraded
35-
Object.keys(opts).forEach(key => {
35+
for (const key of Object.keys(opts)) {
3636
const legacyKey = key.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`);
3737
opts[legacyKey] = opts[key];
38-
});
38+
}
3939

4040
return {opts, args};
4141
});
@@ -201,7 +201,7 @@ if (firstCmd.opts.insight !== false && insight.optOut === undefined) {
201201
} else {
202202
if (firstCmd.opts.insight !== false) {
203203
// Only track the two first subcommands
204-
insight.track.apply(insight, firstCmd.args.slice(0, 2));
204+
insight.track(...firstCmd.args.slice(0, 2));
205205
}
206206

207207
updateCheck();

‎lib/completion/completer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22
const path = require('path');
3-
const execFile = require('child_process').execFile;
3+
const {execFile} = require('child_process');
44
const parseHelp = require('parse-help');
55

66
/**
@@ -43,7 +43,7 @@ class Completer {
4343
* @param {Function} done Callback to invoke with completion results
4444
*/
4545
generator(data, done) {
46-
const last = data.last;
46+
const {last} = data;
4747
const bin = path.resolve(__dirname, '../cli.js');
4848

4949
execFile('node', [bin, last, '--help'], (err, out) => {

‎lib/router.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const humanizeString = require('humanize-string');
66
const readPkgUp = require('read-pkg-up');
77
const updateNotifier = require('update-notifier');
88
const Configstore = require('configstore');
9-
const namespaceToName = require('yeoman-environment').namespaceToName;
9+
const {namespaceToName} = require('yeoman-environment');
1010

1111
/**
1212
* The router is in charge of handling `yo` different screens.
@@ -62,7 +62,7 @@ class Router {
6262
return;
6363
}
6464

65-
const pkg = readPkgUp.sync({cwd: path.dirname(generator.resolved)}).pkg;
65+
const {pkg} = readPkgUp.sync({cwd: path.dirname(generator.resolved)});
6666

6767
if (!pkg) {
6868
return;

‎lib/routes/clear-config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
const _ = require('lodash');
33
const chalk = require('chalk');
44
const inquirer = require('inquirer');
5-
const namespaceToName = require('yeoman-environment').namespaceToName;
5+
const {namespaceToName} = require('yeoman-environment');
66
const globalConfig = require('../utils/global-config');
77

88
module.exports = app => {
@@ -24,7 +24,7 @@ module.exports = app => {
2424
const generator = app.generators[name];
2525

2626
if (generator) {
27-
prettyName = generator.prettyName;
27+
({prettyName} = generator);
2828
sort = -app.conf.get('generatorRunCount')[namespaceToName(generator.namespace)] || 0;
2929
} else {
3030
prettyName = name.replace(/^generator-/, '') + chalk.red(' (not installed anymore)');

‎lib/routes/home.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ const _ = require('lodash');
33
const chalk = require('chalk');
44
const fullname = require('fullname');
55
const inquirer = require('inquirer');
6-
const isString = require('lodash').isString;
7-
const namespaceToName = require('yeoman-environment').namespaceToName;
6+
const {isString} = require('lodash');
7+
const {namespaceToName} = require('yeoman-environment');
88
const globalConfigHasContent = require('../utils/global-config').hasContent;
99

1010
module.exports = app => {

‎lib/routes/install.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports = app => {
4040
}]).then(answers => searchNpm(app, answers.searchTerm));
4141
};
4242

43-
const generatorMatchTerm = (generator, term) => `${generator.name} ${generator.description}`.indexOf(term) !== -1;
43+
const generatorMatchTerm = (generator, term) => `${generator.name} ${generator.description}`.includes(term);
4444
const getAllGenerators = _.memoize(() => npmKeyword('yeoman-generator'));
4545

4646
function searchMatchingGenerators(app, term, cb) {
@@ -49,11 +49,11 @@ function searchMatchingGenerators(app, term, cb) {
4949

5050
getAllGenerators().then(allGenerators => {
5151
cb(null, allGenerators.filter(generator => {
52-
if (blacklist.indexOf(generator.name) !== -1) {
52+
if (blacklist.includes(generator.name)) {
5353
return false;
5454
}
5555

56-
if (installedGenerators.indexOf(generator.name) !== -1) {
56+
if (installedGenerators.includes(generator.name)) {
5757
return false;
5858
}
5959

@@ -68,7 +68,7 @@ function searchMatchingGenerators(app, term, cb) {
6868

6969
function fetchGeneratorInfo(generator, cb) {
7070
packageJson(generator.name).then(pkg => {
71-
const official = OFFICIAL_GENERATORS.indexOf(pkg.name) !== -1;
71+
const official = OFFICIAL_GENERATORS.includes(pkg.name);
7272
const mustache = official ? chalk.green(` ${figures.mustache} `) : '';
7373

7474
cb(null, {

‎lib/routes/run.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22
const chalk = require('chalk');
3-
const namespaceToName = require('yeoman-environment').namespaceToName;
3+
const {namespaceToName} = require('yeoman-environment');
44

55
module.exports = (app, name) => {
66
const baseName = namespaceToName(name);

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"yo-complete": "lib/completion/index.js"
1313
},
1414
"engines": {
15-
"node": ">=4"
15+
"node": ">=6"
1616
},
1717
"scripts": {
1818
"test": "xo && gulp",
@@ -86,7 +86,7 @@
8686
"proxyquire": "^1.0.1",
8787
"registry-url": "^3.0.0",
8888
"sinon": "^1.12.1",
89-
"xo": "^0.18.1"
89+
"xo": "^0.21.1"
9090
},
9191
"tabtab": {
9292
"yo": [

‎test/cli.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22
const path = require('path');
33
const assert = require('assert');
4-
const execFile = require('child_process').execFile;
4+
const {execFile} = require('child_process');
55
const mockery = require('mockery');
66
const pkg = require('../package.json');
77

‎test/completion.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
const path = require('path');
33
const assert = require('assert');
44
const events = require('events');
5-
const execFile = require('child_process').execFile;
6-
const find = require('lodash').find;
5+
const {execFile} = require('child_process');
6+
const {find} = require('lodash');
77
const Completer = require('../lib/completion/completer');
88
const completion = require('../lib/completion');
99

‎test/route-clear-config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe('clear config route', () => {
9898
let choices = [];
9999

100100
this.sandbox.stub(inquirer, 'prompt', arg => {
101-
choices = arg[0].choices;
101+
({choices} = arg[0]);
102102
return Promise.resolve({whatNext: 'foo'});
103103
});
104104
return this.router.navigate('clearConfig').then(() => {

‎test/route-home.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('home route', () => {
5151
it('does not display update options if no generators is installed', function () {
5252
this.router.generator = [];
5353
this.sandbox.stub(inquirer, 'prompt', prompts => {
54-
assert.equal(_.map(prompts[0].choices, 'value').indexOf('update'), -1);
54+
assert.equal(_.map(prompts[0].choices, 'value').includes('update'), false);
5555
return Promise.resolve({whatNext: 'exit'});
5656
});
5757

@@ -67,7 +67,7 @@ describe('home route', () => {
6767
}];
6868

6969
this.sandbox.stub(inquirer, 'prompt', prompts => {
70-
assert(_.map(prompts[0].choices, 'value').indexOf('update') >= 0);
70+
assert(_.map(prompts[0].choices, 'value').includes('update'));
7171
return Promise.resolve({whatNext: 'update'});
7272
});
7373

@@ -108,7 +108,7 @@ describe('home route', () => {
108108
}];
109109

110110
this.sandbox.stub(inquirer, 'prompt', prompts => {
111-
assert(prompts[0].choices[1].name.indexOf('♥ Update Available!') >= 0);
111+
assert(prompts[0].choices[1].name.includes('♥ Update Available!'));
112112
return Promise.resolve({whatNext: 'exit'});
113113
});
114114

‎test/route-install.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ describe('install route', () => {
7979

8080
nock(registryUrl)
8181
.get('/-/v1/search')
82-
.query(true)
83-
.reply(200, {objects: this.packages.map(data => ({package: data}))})
82+
.query(true)
83+
.reply(200, {objects: this.packages.map(data => ({package: data}))})
8484
.filteringPath(/\/[^?]+$/g, '/pkg')
85-
.get('/pkg')
86-
.times(4)
87-
.reply(200, this.pkgData);
85+
.get('/pkg')
86+
.times(4)
87+
.reply(200, this.pkgData);
8888

8989
nock('http://yeoman.io')
9090
.get('/blacklist.json')
@@ -104,7 +104,7 @@ describe('install route', () => {
104104
return Promise.resolve({searchTerm: 'unicorn'});
105105
}
106106
if (call === 2) {
107-
const choices = arg[0].choices;
107+
const {choices} = arg[0];
108108
assert.equal(_.filter(choices, {value: 'generator-foo'}).length, 1);
109109
assert.equal(_.filter(choices, {value: 'generator-unicorn-1'}).length, 1);
110110
assert.equal(_.filter(choices, {value: 'generator-unicorn'}).length, 0);
@@ -126,7 +126,7 @@ describe('install route', () => {
126126
return Promise.resolve({searchTerm: 'blacklist'});
127127
}
128128
if (call === 2) {
129-
const choices = arg[0].choices;
129+
const {choices} = arg[0];
130130
assert.equal(_.filter(choices, {value: 'generator-blacklist-1'}).length, 0);
131131
assert.equal(_.filter(choices, {value: 'generator-blacklist-2'}).length, 0);
132132
assert.equal(_.filter(choices, {value: 'generator-blacklist-3'}).length, 1);
@@ -233,7 +233,7 @@ describe('install route', () => {
233233
}
234234

235235
if (call === 2) {
236-
const choices = arg[0].choices;
236+
const {choices} = arg[0];
237237
assert.deepEqual(_.map(choices, 'value'), ['install', 'home']);
238238
done();
239239
}

0 commit comments

Comments
 (0)
Please sign in to comment.