Skip to content

Commit 20b93cf

Browse files
committed
feat(node): log discovered node version
1 parent 16c8291 commit 20b93cf

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed
+9-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
const chalk = require('chalk');
32
const semver = require('semver');
43

@@ -8,19 +7,22 @@ const checkDirectoryAndAbove = require('./check-directory');
87

98
const taskTitle = 'Checking system Node.js version';
109

11-
function nodeVersion(ctx) {
12-
if (process.env.GHOST_NODE_VERSION_CHECK !== 'false' && !semver.satisfies(process.versions.node, cliPackage.engines.node)) {
13-
return Promise.reject(new errors.SystemError({
10+
async function nodeVersion(ctx, task) {
11+
const {node} = process.versions;
12+
task.title = `${taskTitle} - found v${node}`;
13+
14+
if (process.env.GHOST_NODE_VERSION_CHECK !== 'false' && !semver.satisfies(node, cliPackage.engines.node)) {
15+
throw new errors.SystemError({
1416
message: `${chalk.red('The version of Node.js you are using is not supported.')}
1517
${chalk.gray('Supported: ')}${cliPackage.engines.node}
1618
${chalk.gray('Installed: ')}${process.versions.node}
1719
See ${chalk.underline.blue('https://ghost.org/docs/faq/node-versions/')} for more information`,
1820
task: taskTitle
19-
}));
21+
});
2022
}
2123

2224
if (ctx.local || !ctx.system.platform.linux || (ctx.argv && ctx.argv['setup-linux-user'] === false)) {
23-
return Promise.resolve();
25+
return;
2426
}
2527

2628
return checkDirectoryAndAbove(process.argv[0], 'install node and Ghost-CLI', taskTitle);
@@ -29,5 +31,5 @@ See ${chalk.underline.blue('https://ghost.org/docs/faq/node-versions/')} for mor
2931
module.exports = {
3032
title: taskTitle,
3133
task: nodeVersion,
32-
category: ['install', 'update']
34+
category: ['install', 'update', 'start']
3335
};

test/unit/commands/doctor/checks/node-version-spec.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
const expect = require('chai').expect;
32
const sinon = require('sinon');
43
const stripAnsi = require('strip-ansi');
@@ -37,7 +36,7 @@ describe('Unit: Doctor Checks > nodeVersion', function () {
3736
'../../../../package': cliPackage
3837
}).task;
3938

40-
return nodeVersion().then(() => {
39+
return nodeVersion({}, {}).then(() => {
4140
expect(false, 'error should be thrown').to.be.true;
4241
}).catch((error) => {
4342
expect(error).to.be.an.instanceof(errors.SystemError);
@@ -62,7 +61,7 @@ describe('Unit: Doctor Checks > nodeVersion', function () {
6261
'./check-directory': checkDirectoryStub
6362
}).task;
6463

65-
return nodeVersion({local: true}).then(() => {
64+
return nodeVersion({local: true}, {}).then(() => {
6665
expect(checkDirectoryStub.called).to.be.false;
6766
});
6867
});
@@ -81,7 +80,7 @@ describe('Unit: Doctor Checks > nodeVersion', function () {
8180
'./check-directory': checkDirectoryStub
8281
}).task;
8382

84-
return nodeVersion({local: true}).then(() => {
83+
return nodeVersion({local: true}, {}).then(() => {
8584
expect(checkDirectoryStub.called).to.be.false;
8685
});
8786
});
@@ -100,7 +99,7 @@ describe('Unit: Doctor Checks > nodeVersion', function () {
10099
'./check-directory': checkDirectoryStub
101100
}).task;
102101

103-
return nodeVersion({local: true}).then(() => {
102+
return nodeVersion({local: true}, {}).then(() => {
104103
expect(checkDirectoryStub.called).to.be.false;
105104
});
106105
});
@@ -118,7 +117,7 @@ describe('Unit: Doctor Checks > nodeVersion', function () {
118117
'./check-directory': checkDirectoryStub
119118
}).task;
120119

121-
return nodeVersion({local: true}).then(() => {
120+
return nodeVersion({local: true}, {}).then(() => {
122121
expect(checkDirectoryStub.called).to.be.false;
123122
});
124123
});
@@ -137,7 +136,7 @@ describe('Unit: Doctor Checks > nodeVersion', function () {
137136
'./check-directory': checkDirectoryStub
138137
}).task;
139138

140-
return nodeVersion(ctx).then(() => {
139+
return nodeVersion(ctx, {}).then(() => {
141140
expect(checkDirectoryStub.called).to.be.false;
142141
});
143142
});
@@ -156,7 +155,7 @@ describe('Unit: Doctor Checks > nodeVersion', function () {
156155
'./check-directory': checkDirectoryStub
157156
}).task;
158157

159-
return nodeVersion(ctx).then(() => {
158+
return nodeVersion(ctx, {}).then(() => {
160159
expect(checkDirectoryStub.called).to.be.false;
161160
});
162161
});
@@ -175,7 +174,7 @@ describe('Unit: Doctor Checks > nodeVersion', function () {
175174
'./check-directory': checkDirectoryStub
176175
}).task;
177176

178-
return nodeVersion(ctx).then(() => {
177+
return nodeVersion(ctx, {}).then(() => {
179178
expect(checkDirectoryStub.calledOnce).to.be.true;
180179
expect(checkDirectoryStub.calledWith(process.argv[0])).to.be.true;
181180
});

0 commit comments

Comments
 (0)