Skip to content

Commit 0ca80a7

Browse files
committed
feat(update): run doctor checks on ghost update
no issue - run update checks
1 parent dc419f9 commit 0ca80a7

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

lib/commands/doctor/checks/content-folder.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ module.exports = {
3939
title: 'Content folder permissions',
4040
enabled: () => shouldUseGhostUser(path.join(process.cwd(), 'content')),
4141
task: contentFolderPermissions,
42-
category: ['start']
42+
category: ['start', 'update']
4343
}

lib/commands/doctor/checks/folder-permissions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ Please fix your directory permissions.`));
2121
module.exports = {
2222
title: 'Checking current folder permissions',
2323
task: folderPermissions,
24-
category: ['install']
24+
category: ['install', 'update']
2525
};

lib/commands/doctor/checks/node-version.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ See ${chalk.underline.blue('https://docs.ghost.org/v1/docs/supported-node-versio
2424
module.exports = {
2525
title: 'Checking system Node.js version',
2626
task: nodeVersion,
27-
category: ['install']
27+
category: ['install', 'update']
2828
};

lib/commands/update.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class UpdateCommand extends Command {
1111
const chalk = require('chalk');
1212
const semver = require('semver');
1313

14+
const DoctorCommand = require('./doctor');
1415
const MigrateCommand = require('./migrate');
1516
const migrate = require('../tasks/migrate');
1617

@@ -77,7 +78,12 @@ class UpdateCommand extends Command {
7778
task: this.removeOldVersions
7879
}];
7980

80-
return this.runCommand(MigrateCommand, {quiet: true}).then(() => {
81+
return this.runCommand(DoctorCommand, Object.assign(
82+
{quiet: true, categories: ['update']},
83+
argv
84+
)).then(() => {
85+
return this.runCommand(MigrateCommand, {quiet: true})
86+
}).then(() => {
8187
return this.ui.run(() => this.version(context), 'Checking for latest Ghost version');
8288
}).then((result) => {
8389
if (!result) {

test/unit/commands/update-spec.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('Unit: Commands > Update', function () {
3434
const runCommandStub = sinon.stub(cmdInstance, 'runCommand').resolves();
3535

3636
return cmdInstance.run({version: '1.0.0', force: false, zip: ''}).then(() => {
37-
expect(runCommandStub.calledOnce).to.be.true;
37+
expect(runCommandStub.calledTwice).to.be.true;
3838
expect(ui.run.calledOnce).to.be.true;
3939
expect(versionStub.calledOnce).to.be.true;
4040
expect(versionStub.args[0][0]).to.deep.equal({
@@ -77,7 +77,7 @@ describe('Unit: Commands > Update', function () {
7777
return cmdInstance.run({rollback: true}).then(() => {
7878
expect(false, 'error should have been thrown').to.be.true;
7979
}).catch((error) => {
80-
expect(runCommandStub.calledOnce).to.be.false;
80+
expect(runCommandStub.called).to.be.false;
8181
expect(error).to.be.an.instanceof(Error);
8282
expect(error.message).to.equal('No previous version found');
8383
expect(ui.run.called).to.be.false;
@@ -109,7 +109,7 @@ describe('Unit: Commands > Update', function () {
109109
const cwdStub = sinon.stub(process, 'cwd').returns(fakeInstance.dir);
110110

111111
return cmdInstance.run({rollback: true, force: false, zip: ''}).then(() => {
112-
expect(runCommandStub.calledOnce).to.be.true;
112+
expect(runCommandStub.calledTwice).to.be.true;
113113
cwdStub.restore();
114114

115115
expect(ui.run.calledOnce).to.be.true;
@@ -172,7 +172,7 @@ describe('Unit: Commands > Update', function () {
172172
return cmdInstance.run({version: '1.1.0', rollback: false, force: false, restart: true}).then(() => {
173173
cwdStub.restore();
174174

175-
expect(runCommandStub.calledOnce).to.be.true;
175+
expect(runCommandStub.calledTwice).to.be.true;
176176
expect(ui.run.calledOnce).to.be.true;
177177
expect(versionStub.calledOnce).to.be.true;
178178
expect(ui.log.called).to.be.false;
@@ -238,7 +238,7 @@ describe('Unit: Commands > Update', function () {
238238
zip: ''
239239
};
240240

241-
expect(runCommandStub.calledOnce).to.be.true;
241+
expect(runCommandStub.calledTwice).to.be.true;
242242
expect(ui.run.calledOnce).to.be.true;
243243
expect(versionStub.calledOnce).to.be.true;
244244
expect(versionStub.args[0][0]).to.deep.equal(expectedCtx);
@@ -301,7 +301,7 @@ describe('Unit: Commands > Update', function () {
301301
zip: ''
302302
};
303303

304-
expect(runCommandStub.calledOnce).to.be.true;
304+
expect(runCommandStub.calledTwice).to.be.true;
305305
expect(ui.run.calledOnce).to.be.true;
306306
expect(versionStub.calledOnce).to.be.true;
307307
expect(versionStub.args[0][0]).to.deep.equal(expectedCtx);

0 commit comments

Comments
 (0)