Skip to content

Commit 2f1fcc6

Browse files
committed
fix(linux): make ghost user regex check case insensitive
closes #400 - for `id -u ghost` -> centos returns "No such user" - this made the use-ghost-user check fail
1 parent 05a42f6 commit 2f1fcc6

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/utils/use-ghost-user.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = function useGhostUser(contentDir) {
1616
ghostuid = execa.shellSync('id -u ghost').stdout;
1717
ghostgid = execa.shellSync('id -g ghost').stdout;
1818
} catch (e) {
19-
if (!e.message.match(/no such user/)) {
19+
if (!e.message.match(/no such user/i)) {
2020
throw new errors.ProcessError(e);
2121
}
2222

test/unit/utils/use-ghost-user-spec.js

+14
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,20 @@ describe('Unit: Utils > useGhostUser', function () {
5252
expect(execaStub.calledOnce).to.be.true;
5353
});
5454

55+
it('returns false if "no such error" error is thrown (this time, with caps)', function () {
56+
let platformStub = sinon.stub().returns('linux');
57+
let execaStub = sinon.stub().throws(new Error('No such user'));
58+
let useGhostUser = proxyquire(modulePath, {
59+
os: { platform: platformStub },
60+
execa: { shellSync: execaStub }
61+
});
62+
63+
let result = useGhostUser();
64+
expect(result).to.be.false;
65+
expect(platformStub.calledOnce).to.be.true;
66+
expect(execaStub.calledOnce).to.be.true;
67+
});
68+
5569
it('returns false if the ghost owner/group is not the owner of the content folder', function () {
5670
let platformStub = sinon.stub().returns('linux');
5771
let execaStub = sinon.stub().returns({stdout: '50'});

0 commit comments

Comments
 (0)