diff --git a/lib/update-package.js b/lib/update-package.js index 84ee918..80ab65b 100644 --- a/lib/update-package.js +++ b/lib/update-package.js @@ -28,16 +28,10 @@ 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. // - // Node 0.10.xx + Windows Hack .. Windows does not allow an unlink of a Read-Only file .. - // So we chmod it to be rw by owner... - // This was fixed in node 0.12 + but still is an issue in 0.10.XX which Meteor uses.. - if ( FindNodeVersion(options).substring(0,4) === "0.10" && process.platform === "win32") { - Fs.chmodSync( packagePath, "0644") ; - } - - Fs.unlinkSync(packagePath); - Fs.writeFile(packagePath, JSON.stringify(packageContents, null, 2), done); + Fs.chmodSync( packagePath, "0644" ) ; + Fs.writeFile( packagePath, JSON.stringify(packageContents, null, 2), done); + Fs.chmodSync( packagePath, "0444" ) ; }; 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(); });