Skip to content

Commit

Permalink
Fixed re-pulling with lockfileS
Browse files Browse the repository at this point in the history
  • Loading branch information
mutantcornholio committed Mar 4, 2018
1 parent d8b3be6 commit f28c90b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/install/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function install({force = false, config, rePull = false, lockfile = null}) {
return pushBackends(missingBackends, newPkgJsonHash, config, rePull)
.catch(error => {
if (error instanceof errors.RePullNeeded) {
return install({force: true, rePull: true, config});
return install({force: true, rePull: true, config, lockfile});
}

throw error;
Expand All @@ -142,7 +142,7 @@ function install({force = false, config, rePull = false, lockfile = null}) {
return pushBackends(config.backends, newPkgJsonHash, config, rePull)
.catch(error => {
if (error instanceof errors.RePullNeeded) {
return install({force: true, rePull: true, config});
return install({force: true, rePull: true, config, lockfile});
}

throw error;
Expand Down
30 changes: 28 additions & 2 deletions test/unit/install/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1040,8 +1040,8 @@ describe('install', () => {

fakeBackends[1].backend.pull = () => Promise.reject(new errors.BundleNotFoundError);
const backendMock0 = sandbox.mock(fakeBackends[0].backend);
npmWrapper.installAll.restore();

npmWrapper.installAll.restore();
sandbox.stub(npmWrapper, 'installAll').callsFake(() => {
mockfs({
'package.json': JSON.stringify(PKGJSON),
Expand All @@ -1051,13 +1051,39 @@ describe('install', () => {
return Promise.resolve();
});


backendMock0.expects('push').withArgs('PKGJSONHashWithNewLockfile').resolves();

const checkResult = checkMockResult.bind(null, [backendMock0], done);

install({config}).then(checkResult, checkResult);
});

it('re-pulling should work after hash recalculation', done => {
const backendMock0 = sandbox.mock(fakeBackends[0].backend);

backendMock0.expects('pull').withArgs('PKGJSONHash').rejects(new errors.BundleNotFoundError);
fakeBackends[1].backend.pull = () => Promise.reject(new errors.BundleNotFoundError);

backendMock0.expects('push')
.withArgs('PKGJSONHashWithNewLockfile')
.rejects(new errors.BundleAlreadyExistsError);

backendMock0.expects('pull').withArgs('PKGJSONHashWithNewLockfile').resolves();

npmWrapper.installAll.restore();
sandbox.stub(npmWrapper, 'installAll').callsFake(() => {
mockfs({
'package.json': JSON.stringify(PKGJSON),
'package-lock.json': JSON.stringify(LOCKFILE),
});

return Promise.resolve();
});

const checkResult = checkMockResult.bind(null, [backendMock0], done);

install({config}).then(checkResult, checkResult);
});
});
});

Expand Down

0 comments on commit f28c90b

Please sign in to comment.