Skip to content

Commit 0e22e64

Browse files
feat(extensions): add user skipped task hook
refs TryGhost#308, TryGhost#1115
1 parent 1a1fece commit 0e22e64

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

extensions/systemd/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ class SystemdExtension extends Extension {
2222
}
2323

2424
return false;
25+
},
26+
onUserSkip: ({instance, ui}) => {
27+
ui.log('Systemd setup skipped, reverting to local process manager', 'yellow');
28+
instance.config.set('process', 'local').save();
2529
}
2630
}];
2731
}

extensions/systemd/test/extension-spec.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('Unit: Systemd > Extension', function () {
2424
expect(tasks[0].id).to.equal('systemd');
2525
expect(tasks[0].name).to.equal('Systemd');
2626

27-
const [{enabled, task, skip}] = tasks;
27+
const [{enabled, task, skip, onUserSkip}] = tasks;
2828
const config = configStub();
2929
const instance = {config, name: 'test_instance'};
3030

@@ -55,6 +55,11 @@ describe('Unit: Systemd > Extension', function () {
5555

5656
expect(skip({instance})).to.be.false;
5757
expect(exists.calledOnce).to.be.true;
58+
59+
config.set.resetHistory();
60+
expect(onUserSkip).to.be.a('function');
61+
onUserSkip({instance});
62+
expect(config.set.calledOnceWithExactly('process', 'local')).to.be.true;
5863
});
5964

6065
describe('setup stage', function () {

lib/commands/setup.js

+4
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ class SetupCommand extends Command {
141141

142142
const confirmed = await this.ui.confirm(`Do you wish to set up ${name}?`, true);
143143
if (!confirmed) {
144+
if (step.onUserSkip) {
145+
await step.onUserSkip(ctx);
146+
}
147+
144148
return task.skip();
145149
}
146150

0 commit comments

Comments
 (0)