diff --git a/lib/install/index.js b/lib/install/index.js index e866f7e..5ebfc88 100644 --- a/lib/install/index.js +++ b/lib/install/index.js @@ -104,25 +104,6 @@ function install({force = false, config, rePull = false, lockfile = null}) { throw error; }) - .then(() => { - if (lockfile === null) { - return resolveLockfile().then(resolvedLockfile => lockfile = resolvedLockfile); - } - }) - .then(() => { - if (lockfile === null) { - return; - } - - return fsExtra.readFile(lockfile) - .then(lockfileBuf => { - newLockfileContents = JSON.parse(lockfileBuf.toString()); - newPkgJsonHash = pkgJsonUtils.calcHash(newPkgJson, newLockfileContents, config.packageHash); - - logger.info(`New hash is:\t${newPkgJsonHash}`); - }) - - }) .then(() => { if (done) { if (missingBackends.length > 0) { diff --git a/test/integration/testCases/gitPush/testcase.sh b/test/integration/testCases/gitPush/testcase.sh index f992726..dbcbd5d 100644 --- a/test/integration/testCases/gitPush/testcase.sh +++ b/test/integration/testCases/gitPush/testcase.sh @@ -12,14 +12,8 @@ cd repolocal npm_ver="$(npm --version)" -if [[ "$npm_ver" == 3* ]] || [[ "$npm_ver" == 4* ]]; then - git checkout veendor-7d0db335c82dfd9aa2b96dabc485b89ebaa1496f - tar -xf 7d0db335c82dfd9aa2b96dabc485b89ebaa1496f.tar.gz -else - git checkout veendor-1722dc5c5ee28cf0bcdc5ac1da82e0608b655f88 - tar -xf 1722dc5c5ee28cf0bcdc5ac1da82e0608b655f88.tar.gz # package-lock.json is created during the run - # veendor should recalculate hash and push new one -fi +git checkout veendor-7d0db335c82dfd9aa2b96dabc485b89ebaa1496f +tar -xf 7d0db335c82dfd9aa2b96dabc485b89ebaa1496f.tar.gz if [[ ! -f "node_modules/deep-object-diff/package.json" ]]; then echo "gitPush failed; node_modules/deep-object-diff/package.json is not there" diff --git a/test/integration/testCases/localPush/testcase.sh b/test/integration/testCases/localPush/testcase.sh index eaccf88..07f1177 100644 --- a/test/integration/testCases/localPush/testcase.sh +++ b/test/integration/testCases/localPush/testcase.sh @@ -10,12 +10,7 @@ node "$rootdir/bin/veendor.js" install --debug npm_ver="$(npm --version)" cd "$(pwd)/local" -if [[ "$npm_ver" == 3* ]] || [[ "$npm_ver" == 4* ]]; then - tar -xf 7d0db335c82dfd9aa2b96dabc485b89ebaa1496f.tar.gz -else - tar -xf 1722dc5c5ee28cf0bcdc5ac1da82e0608b655f88.tar.gz # package-lock.json is created during the run - # veendor should recalculate hash and push new one -fi +tar -xf 7d0db335c82dfd9aa2b96dabc485b89ebaa1496f.tar.gz if [[ ! -f "node_modules/deep-object-diff/package.json" ]]; then echo "gitPush failed; node_modules/deep-object-diff/package.json is not there" diff --git a/test/unit/install/index.test.js b/test/unit/install/index.test.js index da96ed0..487c58c 100644 --- a/test/unit/install/index.test.js +++ b/test/unit/install/index.test.js @@ -1003,87 +1003,6 @@ describe('install', () => { assert.isRejected(install({config}), errors.BundleAlreadyExistsError).notify(done); }); - - it('should re-calc hash after npm install', done => { - // because npm install with lockfile will change the lockfile and we need to push with new hash - mockfs({ - 'package.json': JSON.stringify(PKGJSON), - 'package-lock.json': JSON.stringify(olderLockfiles[0]), - }); - - fakeBackends[1].backend.pull = () => Promise.reject(new errors.BundleNotFoundError); - const backendMock0 = sandbox.mock(fakeBackends[0].backend); - npmWrapper.installAll.restore(); - - sandbox.stub(npmWrapper, 'installAll').callsFake(() => { - mockfs({ - 'package.json': JSON.stringify(PKGJSON), - 'package-lock.json': JSON.stringify(LOCKFILE), - }); - - return Promise.resolve(); - }); - - - backendMock0.expects('push').withArgs('PKGJSONHashWithNewLockfile').resolves(); - - const checkResult = checkMockResult.bind(null, [backendMock0], done); - - install({config, lockfile: 'package-lock.json'}).then(checkResult, checkResult); - }); - - it('should locate lockfile and re-calc hash after npm install', done => { - // because npm install with lockfile will change the lockfile and we need to push with new hash - mockfs({ - 'package.json': JSON.stringify(PKGJSON), - }); - - fakeBackends[1].backend.pull = () => Promise.reject(new errors.BundleNotFoundError); - const backendMock0 = sandbox.mock(fakeBackends[0].backend); - - npmWrapper.installAll.restore(); - sandbox.stub(npmWrapper, 'installAll').callsFake(() => { - mockfs({ - 'package.json': JSON.stringify(PKGJSON), - 'package-lock.json': JSON.stringify(LOCKFILE), - }); - - 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); - }); }); });