Skip to content

Commit 2ca819d

Browse files
author
Matt Hernandez
committed
Merge pull request #144 from Galaxy-Semi/master
Fix# 143 - EPERM error in Windows
2 parents 99dc8d1 + 5e290b9 commit 2ca819d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/update-package.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ module.exports = function (options, done) {
2828
Hoek.merge(packageContents, options.json || {});
2929

3030
//
31-
// The generated package.json is read-only, but removing it prior to writing
32-
// will allow updates.
31+
// Change the file permissions so we can over-write the package. Then we'll write the package
32+
// and then change the file permissions back to read-only.
3333
//
34-
Fs.unlinkSync(packagePath);
34+
Fs.chmodSync(packagePath, '0644') ;
3535
Fs.writeFile(packagePath, JSON.stringify(packageContents, null, 2), done);
3636
};

test/update-package.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('update-package', function () {
4545
before(function (done) {
4646
fsStub.existsSync = Sinon.stub().returns(true);
4747
fsStub.readFileSync = Sinon.stub().returns('{}');
48-
fsStub.unlinkSync = Sinon.stub();
48+
fsStub.chmodSync = Sinon.stub();
4949
fsStub.writeFile = Sinon.stub().yields(null);
5050
done();
5151
});
@@ -62,7 +62,7 @@ describe('update-package', function () {
6262
before(function (done) {
6363
fsStub.existsSync = Sinon.stub().returns(true);
6464
fsStub.readFileSync = Sinon.stub().returns('{}');
65-
fsStub.unlinkSync = Sinon.stub();
65+
fsStub.chmodSync = Sinon.stub();
6666
fsStub.writeFile = Sinon.stub().yields(null);
6767
done();
6868
});

0 commit comments

Comments
 (0)