Skip to content

Commit

Permalink
fix: revert
Browse files Browse the repository at this point in the history
switch over to synchronous version
  • Loading branch information
jamesgeorge007 committed Aug 17, 2019
1 parent 95c122b commit a20969e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 34 deletions.
17 changes: 2 additions & 15 deletions bin/eslint.js
Expand Up @@ -57,19 +57,6 @@ process.once("uncaughtException", err => {
process.exitCode = 2;
});

/**
* Handles the condition based Promise as returned by cli.execute()
* @param {string | void} arg argument to be passed in
* @returns {void}
*/
async function handleArgs(arg) {
const exitCode = cli.execute(process.argv, arg ? arg : null);

process.exitCode = exitCode instanceof Promise // eslint-disable-line
? await exitCode
: exitCode;
}

if (useStdIn) {

/*
Expand All @@ -79,7 +66,7 @@ if (useStdIn) {
*/
const STDIN_FILE_DESCRIPTOR = 0;

handleArgs(fs.readFileSync(STDIN_FILE_DESCRIPTOR, "utf8"));
process.exitCode = cli.execute(process.argv, fs.readFileSync(STDIN_FILE_DESCRIPTOR, "utf8"));
} else if (init) {
const configInit = require("../lib/init/config-initializer");

Expand All @@ -91,5 +78,5 @@ if (useStdIn) {
console.error(err.stack);
});
} else {
handleArgs();
process.exitCode = cli.execute(process.argv);
}
30 changes: 15 additions & 15 deletions lib/cli.js
Expand Up @@ -18,7 +18,7 @@
const fs = require("fs"),
path = require("path"),
mkdirp = require("mkdirp"),
envinfo = require("envinfo"),
{ execSync } = require("child_process"),
{ CLIEngine } = require("./cli-engine"),
options = require("./options"),
log = require("./shared/logging");
Expand Down Expand Up @@ -184,20 +184,20 @@ const cli = {
log.info(JSON.stringify(fileConfig, null, " "));
return 0;
} else if (currentOptions.info) {
return new Promise(resolve => {
log.info("\n Environment Information:-");
envinfo
.run({
System: ["OS", "CPU"],
Binaries: ["Node", "Yarn", "npm"],
npmPackages: "eslint-{config,plugin}-*",
npmGlobalPackages: ["eslint"]
})
.then(log.info)
.catch(err => {
throw err;
});
resolve(2);
log.info("\n Environment Information:-\n");
const packageInfo = {
node: "node -v",
npm: "npm -v",
eslint: "eslint -v"
};

Object.keys(packageInfo).forEach(pkg => {
try {
log.info(` ${pkg}: ${execSync(packageInfo[pkg])}`);
} catch (err) {

// handle err
}
});
} else if (currentOptions.help || (!files.length && !useStdin)) {

Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -49,7 +49,6 @@
"cross-spawn": "^6.0.5",
"debug": "^4.0.1",
"doctrine": "^3.0.0",
"envinfo": "^7.3.1",
"eslint-scope": "^5.0.0",
"eslint-utils": "^1.3.1",
"eslint-visitor-keys": "^1.0.0",
Expand Down
6 changes: 3 additions & 3 deletions tests/lib/cli.js
Expand Up @@ -1113,9 +1113,9 @@ describe("cli", () => {
});

describe("when passing --info", () => {
it("should print out debugging information concerning the local environment", async() => {
await cli.execute("--info");
assert.isTrue(log.info.calledTwice);
it("should print out debugging information concerning the local environment", () => {
cli.execute("--info");
assert.isTrue(log.info.called);
});
});

Expand Down

0 comments on commit a20969e

Please sign in to comment.