Skip to content

Commit 7dabc38

Browse files
authored
fix: use process.version in --env-info (#19865)
1 parent 4112fd0 commit 7dabc38

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

lib/shared/runtime-info.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ function environment() {
150150
return [
151151
"Environment Info:",
152152
"",
153-
`Node version: ${getBinVersion("node")}`,
153+
`Node version: ${process.version}`,
154154
`npm version: ${getBinVersion("npm")}`,
155155
`Local ESLint version: ${getNpmPackageVersion("eslint", { global: false })}`,
156156
`Global ESLint version: ${getNpmPackageVersion("eslint", { global: true })}`,

tests/lib/shared/runtime-info.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ describe("RuntimeInfo", () => {
5555
describe("environment()", () => {
5656
let spawnSyncStub;
5757
let logErrorStub;
58+
let processVersionStub;
5859
let originalProcessArgv;
5960
let spawnSyncStubArgs;
6061
const originalOsPlatform = os.platform;
@@ -65,10 +66,12 @@ describe("RuntimeInfo", () => {
6566
os.release = () => "20.3.0";
6667
spawnSyncStub = sinon.stub(spawn, "sync");
6768
logErrorStub = sinon.stub(log, "error");
69+
processVersionStub = sinon
70+
.stub(process, "version")
71+
.value("v12.8.0");
6872
originalProcessArgv = process.argv;
6973
process.argv[1] = LOCAL_ESLINT_BIN_PATH;
7074
spawnSyncStubArgs = [
71-
"v12.8.0",
7275
"6.11.3",
7376
unIndent`
7477
{
@@ -99,6 +102,7 @@ describe("RuntimeInfo", () => {
99102
afterEach(() => {
100103
spawnSyncStub.restore();
101104
logErrorStub.restore();
105+
processVersionStub.restore();
102106
process.argv = originalProcessArgv;
103107
os.platform = originalOsPlatform;
104108
os.release = originalOsRelease;
@@ -141,7 +145,7 @@ describe("RuntimeInfo", () => {
141145

142146
it("should return a string containing environment information when not installed locally", () => {
143147
spawnSyncStubArgs.splice(
144-
2,
148+
1,
145149
2,
146150
unIndent`
147151
{
@@ -169,7 +173,7 @@ describe("RuntimeInfo", () => {
169173
});
170174

171175
it("should return a string containing environment information when not installed globally", () => {
172-
spawnSyncStubArgs[4] = "{}";
176+
spawnSyncStubArgs[3] = "{}";
173177
setupSpawnSyncStubReturnVals(spawnSyncStub, spawnSyncStubArgs);
174178

175179
assert.strictEqual(
@@ -189,7 +193,7 @@ describe("RuntimeInfo", () => {
189193
it("log and throw an error when npm version can not be found", () => {
190194
const expectedErr = new Error("npm can not be found");
191195

192-
spawnSyncStubArgs[1] = expectedErr;
196+
spawnSyncStubArgs[0] = expectedErr;
193197
setupSpawnSyncStubReturnVals(spawnSyncStub, spawnSyncStubArgs);
194198

195199
assert.throws(RuntimeInfo.environment, expectedErr);
@@ -202,7 +206,7 @@ describe("RuntimeInfo", () => {
202206
it("log and throw an error when npm binary path can not be found", () => {
203207
const expectedErr = new Error("npm can not be found");
204208

205-
spawnSyncStubArgs[3] = expectedErr;
209+
spawnSyncStubArgs[2] = expectedErr;
206210
setupSpawnSyncStubReturnVals(spawnSyncStub, spawnSyncStubArgs);
207211

208212
assert.throws(RuntimeInfo.environment, expectedErr);
@@ -213,7 +217,7 @@ describe("RuntimeInfo", () => {
213217
});
214218

215219
it("log and throw an error when checking for local ESLint version when returned output of command is malformed", () => {
216-
spawnSyncStubArgs[2] = "This is not JSON";
220+
spawnSyncStubArgs[1] = "This is not JSON";
217221
setupSpawnSyncStubReturnVals(spawnSyncStub, spawnSyncStubArgs);
218222

219223
assert.throws(
@@ -227,7 +231,7 @@ describe("RuntimeInfo", () => {
227231
});
228232

229233
it("log and throw an error when checking for global ESLint version when returned output of command is malformed", () => {
230-
spawnSyncStubArgs[4] = "This is not JSON";
234+
spawnSyncStubArgs[3] = "This is not JSON";
231235
setupSpawnSyncStubReturnVals(spawnSyncStub, spawnSyncStubArgs);
232236

233237
assert.throws(

0 commit comments

Comments
 (0)