Skip to content

Commit

Permalink
Upgrade: dependencies (#8304)
Browse files Browse the repository at this point in the history
  • Loading branch information
alberto authored and gyandeeps committed Apr 12, 2017
1 parent 48700fc commit 288c96c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 66 deletions.
14 changes: 6 additions & 8 deletions bin/eslint.js
Expand Up @@ -61,14 +61,12 @@ if (useStdIn) {
} else if (init) {
const configInit = require("../lib/config/config-initializer");

configInit.initializeConfig(err => {
if (err) {
process.exitCode = 1;
console.error(err.message);
console.error(err.stack);
} else {
process.exitCode = 0;
}
configInit.initializeConfig().then(() => {
process.exitCode = 0;
}).catch(err => {
process.exitCode = 1;
console.error(err.message);
console.error(err.stack);
});
} else {
process.exitCode = cli.execute(process.argv);
Expand Down
68 changes: 28 additions & 40 deletions lib/config/config-initializer.js
Expand Up @@ -282,13 +282,12 @@ function getConfigForStyleGuide(guide) {
/* istanbul ignore next: no need to test inquirer*/
/**
* Ask use a few questions on command prompt
* @param {Function} callback callback function when file has been written
* @returns {void}
* @returns {Promise} The promise with the result of the prompt
*/
function promptUser(callback) {
function promptUser() {
let config;

inquirer.prompt([
return inquirer.prompt([
{
type: "list",
name: "source",
Expand Down Expand Up @@ -343,29 +342,26 @@ function promptUser(callback) {
return ((answers.source === "guide" && answers.packageJsonExists) || answers.source === "auto");
}
}
], earlyAnswers => {
]).then(earlyAnswers => {

// early exit if you are using a style guide
if (earlyAnswers.source === "guide") {
if (!earlyAnswers.packageJsonExists) {
log.info("A package.json is necessary to install plugins such as style guides. Run `npm init` to create a package.json file and try again.");
return;
return void 0;
}
if (earlyAnswers.styleguide === "airbnb" && !earlyAnswers.airbnbReact) {
earlyAnswers.styleguide = "airbnb-base";
}
try {
config = getConfigForStyleGuide(earlyAnswers.styleguide);
writeFile(config, earlyAnswers.format);
} catch (err) {
callback(err);
return;
}
return;

config = getConfigForStyleGuide(earlyAnswers.styleguide);
writeFile(config, earlyAnswers.format);

return void 0;
}

// continue with the questions otherwise...
inquirer.prompt([
return inquirer.prompt([
{
type: "confirm",
name: "es6",
Expand Down Expand Up @@ -412,25 +408,21 @@ function promptUser(callback) {
return answers.jsx;
}
}
], secondAnswers => {
]).then(secondAnswers => {

// early exit if you are using automatic style generation
if (earlyAnswers.source === "auto") {
try {
const combinedAnswers = Object.assign({}, earlyAnswers, secondAnswers);

config = processAnswers(combinedAnswers);
installModules(config);
writeFile(config, earlyAnswers.format);
} catch (err) {
callback(err);
return;
}
return;
const combinedAnswers = Object.assign({}, earlyAnswers, secondAnswers);

config = processAnswers(combinedAnswers);
installModules(config);
writeFile(config, earlyAnswers.format);

return void 0;
}

// continue with the style questions otherwise...
inquirer.prompt([
return inquirer.prompt([
{
type: "list",
name: "indent",
Expand Down Expand Up @@ -465,16 +457,12 @@ function promptUser(callback) {
default: "JavaScript",
choices: ["JavaScript", "YAML", "JSON"]
}
], answers => {
try {
const totalAnswers = Object.assign({}, earlyAnswers, secondAnswers, answers);

config = processAnswers(totalAnswers);
installModules(config);
writeFile(config, answers.format);
} catch (err) {
callback(err); // eslint-disable-line callback-return
}
]).then(answers => {
const totalAnswers = Object.assign({}, earlyAnswers, secondAnswers, answers);

config = processAnswers(totalAnswers);
installModules(config);
writeFile(config, answers.format);
});
});
});
Expand All @@ -487,8 +475,8 @@ function promptUser(callback) {
const init = {
getConfigForStyleGuide,
processAnswers,
/* istanbul ignore next */initializeConfig(callback) {
promptUser(callback);
/* istanbul ignore next */initializeConfig() {
return promptUser();
}
};

Expand Down
2 changes: 1 addition & 1 deletion lib/formatters/table.js
Expand Up @@ -9,7 +9,7 @@
//------------------------------------------------------------------------------

const chalk = require("chalk"),
table = require("table").default,
table = require("table").table,
pluralize = require("pluralize");

//------------------------------------------------------------------------------
Expand Down
34 changes: 17 additions & 17 deletions package.json
Expand Up @@ -34,39 +34,39 @@
"homepage": "http://eslint.org",
"bugs": "https://github.com/eslint/eslint/issues/",
"dependencies": {
"babel-code-frame": "^6.16.0",
"babel-code-frame": "^6.22.0",
"chalk": "^1.1.3",
"concat-stream": "^1.5.2",
"debug": "^2.1.1",
"concat-stream": "^1.6.0",
"debug": "^2.6.3",
"doctrine": "^2.0.0",
"eslint-scope": "^3.6.0",
"espree": "^3.4.0",
"esquery": "^1.0.0",
"estraverse": "^4.2.0",
"esutils": "^2.0.2",
"file-entry-cache": "^2.0.0",
"glob": "^7.0.3",
"globals": "^9.14.0",
"ignore": "^3.2.0",
"glob": "^7.1.1",
"globals": "^9.16.0",
"ignore": "^3.2.6",
"imurmurhash": "^0.1.4",
"inquirer": "^0.12.0",
"is-my-json-valid": "^2.10.0",
"inquirer": "^3.0.6",
"is-my-json-valid": "^2.16.0",
"is-resolvable": "^1.0.0",
"js-yaml": "^3.5.1",
"json-stable-stringify": "^1.0.0",
"js-yaml": "^3.8.2",
"json-stable-stringify": "^1.0.1",
"levn": "^0.3.0",
"lodash": "^4.0.0",
"mkdirp": "^0.5.0",
"lodash": "^4.17.4",
"mkdirp": "^0.5.1",
"natural-compare": "^1.4.0",
"optionator": "^0.8.2",
"path-is-inside": "^1.0.1",
"pluralize": "^1.2.1",
"path-is-inside": "^1.0.2",
"pluralize": "^4.0.0",
"progress": "^1.1.8",
"require-uncached": "^1.0.2",
"shelljs": "^0.7.5",
"require-uncached": "^1.0.3",
"shelljs": "^0.7.7",
"strip-bom": "^3.0.0",
"strip-json-comments": "~2.0.1",
"table": "^3.7.8",
"table": "^4.0.1",
"text-table": "~0.2.0",
"user-home": "^2.0.0"
},
Expand Down

0 comments on commit 288c96c

Please sign in to comment.