diff --git a/lib/update-package.js b/lib/update-package.js index 5e18f4b..ed49bda 100644 --- a/lib/update-package.js +++ b/lib/update-package.js @@ -28,9 +28,9 @@ module.exports = function (options, done) { Hoek.merge(packageContents, options.json || {}); // - // The generated package.json is read-only, but removing it prior to writing - // will allow updates. + // Change the file permissions so we can over-write the package. Then we'll write the package + // and then change the file permissions back to read-only. // - Fs.unlinkSync(packagePath); + Fs.chmodSync(packagePath, '0644') ; Fs.writeFile(packagePath, JSON.stringify(packageContents, null, 2), done); }; diff --git a/test/update-package.js b/test/update-package.js index bd1f94e..474cfd0 100644 --- a/test/update-package.js +++ b/test/update-package.js @@ -45,7 +45,7 @@ describe('update-package', function () { before(function (done) { fsStub.existsSync = Sinon.stub().returns(true); fsStub.readFileSync = Sinon.stub().returns('{}'); - fsStub.unlinkSync = Sinon.stub(); + fsStub.chmodSync = Sinon.stub(); fsStub.writeFile = Sinon.stub().yields(null); done(); }); @@ -62,7 +62,7 @@ describe('update-package', function () { before(function (done) { fsStub.existsSync = Sinon.stub().returns(true); fsStub.readFileSync = Sinon.stub().returns('{}'); - fsStub.unlinkSync = Sinon.stub(); + fsStub.chmodSync = Sinon.stub(); fsStub.writeFile = Sinon.stub().yields(null); done(); });