Skip to content

Commit 47ad7f6

Browse files
committed
fix(local-process): ensure string argument is passed to writeFileSync
1 parent 9e12e0a commit 47ad7f6

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/utils/local-process.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Ensure the content folder has correct permissions and try again.`));
4444
});
4545

4646
// Stick the pid into the pidfile so we can stop the process later
47-
fs.writeFileSync(path.join(cwd, PID_FILE), cp.pid);
47+
fs.writeFileSync(path.join(cwd, PID_FILE), cp.pid.toString());
4848

4949
cp.stderr.on('data', (data) => {
5050
errorBuffer += data.toString();

test/unit/utils/local-process-spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ describe('Unit: Utils > local-process', function () {
141141
expect(error.message).to.equal('An error occurred while starting Ghost.');
142142
expect(spawnStub.calledOnce).to.be.true;
143143
expect(cp.stderr.on.calledOnce).to.be.true;
144-
expect(writeFileStub.calledWithExactly('/var/www/ghost/.ghostpid', 42)).to.be.true;
144+
expect(writeFileStub.calledWithExactly('/var/www/ghost/.ghostpid', '42')).to.be.true;
145145
done();
146146
});
147147

@@ -173,7 +173,7 @@ describe('Unit: Utils > local-process', function () {
173173
expect(error.message).to.equal('Ghost process exited with code: 1');
174174
expect(spawnStub.calledOnce).to.be.true;
175175
expect(cp.stderr.on.calledOnce).to.be.true;
176-
expect(writeFileStub.calledWithExactly('/var/www/ghost/.ghostpid', 42)).to.be.true;
176+
expect(writeFileStub.calledWithExactly('/var/www/ghost/.ghostpid', '42')).to.be.true;
177177
expect(removeStub.calledWithExactly('/var/www/ghost/.ghostpid')).to.be.true;
178178
done();
179179
});
@@ -206,7 +206,7 @@ describe('Unit: Utils > local-process', function () {
206206
expect(error.message).to.equal('Test Error Message');
207207
expect(spawnStub.called).to.be.true;
208208
expect(cp.stderr.on.calledOnce).to.be.true;
209-
expect(writeFileStub.calledWithExactly('/var/www/ghost/.ghostpid', 42)).to.be.true;
209+
expect(writeFileStub.calledWithExactly('/var/www/ghost/.ghostpid', '42')).to.be.true;
210210
expect(removeStub.calledWithExactly('/var/www/ghost/.ghostpid')).to.be.true;
211211
done();
212212
});
@@ -236,7 +236,7 @@ describe('Unit: Utils > local-process', function () {
236236

237237
startPromise.then(() => {
238238
expect(spawnStub.calledOnce).to.be.true;
239-
expect(writeFileStub.calledWithExactly('/var/www/ghost/.ghostpid', 42)).to.be.true;
239+
expect(writeFileStub.calledWithExactly('/var/www/ghost/.ghostpid', '42')).to.be.true;
240240
expect(cp.stderr.on.calledOnce).to.be.true;
241241
expect(cp.stderr.destroy.calledOnce).to.be.true;
242242
expect(cp.disconnect.calledOnce).to.be.true;

0 commit comments

Comments
 (0)