Skip to content

Commit 208bb15

Browse files
aileenacburdine
authored andcommitted
fix(systemd): improve systemd precheck error messages (#628)
1 parent a195fc1 commit 208bb15

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

extensions/systemd/systemd.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const fs = require('fs');
44
const execa = require('execa');
55
const cli = require('../../lib');
66
const getUid = require('./get-uid');
7+
const chalk = require('chalk');
78

89
class SystemdProcessManager extends cli.ProcessManager {
910
get systemdName() {
@@ -101,14 +102,20 @@ class SystemdProcessManager extends cli.ProcessManager {
101102
const uid = getUid(this.instance.dir);
102103

103104
if (!uid) {
104-
throw new cli.errors.SystemError('Systemd process manager has not been set up. Run `ghost setup linux-user systemd` and try again.')
105+
throw new cli.errors.SystemError({
106+
message: 'Systemd process manager has not been set up or is corrupted.',
107+
help: `Run ${chalk.green('ghost setup linux-user systemd')} and try again.`
108+
});
105109
}
106110

107111
if (fs.existsSync(`/lib/systemd/system/${this.systemdName}.service`)) {
108112
return;
109113
}
110114

111-
throw new cli.errors.SystemError('Systemd process manager has not been set up. Run `ghost setup systemd` and try again.');
115+
throw new cli.errors.SystemError({
116+
message: 'Systemd process manager has not been set up or is corrupted.',
117+
help: `Run ${chalk.green('ghost setup systemd')} and try again.`
118+
});
112119
}
113120

114121
static willRun() {

extensions/systemd/test/systemd-spec.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ describe('Unit: Systemd > Process Manager', function () {
310310
expect(proxyOpts['./get-uid'].calledOnce).to.be.true;
311311
expect(error).to.be.ok;
312312
expect(error).to.be.instanceOf(errors.SystemError);
313-
expect(error.message).to.match(/ghost setup linux-user systemd/);
313+
expect(error.message).to.match(/Systemd process manager has not been set up or is corrupted./);
314+
expect(error.options.help).to.match(/ghost setup linux-user systemd/);
314315
}
315316
});
316317

@@ -337,7 +338,8 @@ describe('Unit: Systemd > Process Manager', function () {
337338
expect(fsStub.calledOnce).to.be.true;
338339
expect(error).to.be.ok;
339340
expect(error).to.be.instanceOf(errors.SystemError);
340-
expect(error.message).to.match(/ghost setup systemd/);
341+
expect(error.message).to.match(/Systemd process manager has not been set up or is corrupted./);
342+
expect(error.options.help).to.match(/ghost setup systemd/);
341343
}
342344
});
343345
});

0 commit comments

Comments
 (0)