Skip to content

Commit

Permalink
Update: eslint --env-info output os info (#14059)
Browse files Browse the repository at this point in the history
* Update: eslint --env-info ouput os info

* chore: rm pkg os-name

* chore: resotre original os.platform & os.release
  • Loading branch information
aladdin-add committed Mar 20, 2021
1 parent 2a79306 commit 8984c91
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/shared/runtime-info.js
Expand Up @@ -11,6 +11,7 @@

const path = require("path");
const spawn = require("cross-spawn");
const os = require("os");
const log = require("../shared/logging");
const packageJson = require("../../package.json");

Expand Down Expand Up @@ -140,7 +141,8 @@ function environment() {
`Node version: ${getBinVersion("node")}`,
`npm version: ${getBinVersion("npm")}`,
`Local ESLint version: ${getNpmPackageVersion("eslint", { global: false })}`,
`Global ESLint version: ${getNpmPackageVersion("eslint", { global: true })}`
`Global ESLint version: ${getNpmPackageVersion("eslint", { global: true })}`,
`Operating System: ${os.platform()} ${os.release()}`
].join("\n");
}

Expand Down
11 changes: 11 additions & 0 deletions tests/lib/shared/runtime-info.js
Expand Up @@ -12,6 +12,7 @@
const assert = require("chai").assert;
const sinon = require("sinon");
const spawn = require("cross-spawn");
const os = require("os");
const { unIndent } = require("../../_utils");
const RuntimeInfo = require("../../../lib/shared/runtime-info");
const log = require("../../../lib/shared/logging");
Expand Down Expand Up @@ -55,8 +56,12 @@ describe("RuntimeInfo", () => {
let logErrorStub;
let originalProcessArgv;
let spawnSyncStubArgs;
const originalOsPlatform = os.platform;
const originalOsRelease = os.release;

beforeEach(() => {
os.platform = () => "darwin";
os.release = () => "20.3.0";
spawnSyncStub = sinon.stub(spawn, "sync");
logErrorStub = sinon.stub(log, "error");
originalProcessArgv = process.argv;
Expand Down Expand Up @@ -94,6 +99,8 @@ describe("RuntimeInfo", () => {
spawnSyncStub.restore();
logErrorStub.restore();
process.argv = originalProcessArgv;
os.platform = originalOsPlatform;
os.release = originalOsRelease;
});


Expand All @@ -109,6 +116,7 @@ describe("RuntimeInfo", () => {
npm version: v6.11.3
Local ESLint version: v6.3.0 (Currently used)
Global ESLint version: v5.16.0
Operating System: darwin 20.3.0
`
);
});
Expand All @@ -126,6 +134,7 @@ describe("RuntimeInfo", () => {
npm version: v6.11.3
Local ESLint version: v6.3.0
Global ESLint version: v5.16.0 (Currently used)
Operating System: darwin 20.3.0
`
);
});
Expand All @@ -150,6 +159,7 @@ describe("RuntimeInfo", () => {
npm version: v6.11.3
Local ESLint version: Not found
Global ESLint version: v5.16.0 (Currently used)
Operating System: darwin 20.3.0
`
);
});
Expand All @@ -167,6 +177,7 @@ describe("RuntimeInfo", () => {
npm version: v6.11.3
Local ESLint version: v6.3.0 (Currently used)
Global ESLint version: Not found
Operating System: darwin 20.3.0
`
);
});
Expand Down

0 comments on commit 8984c91

Please sign in to comment.