From c8d37605ede6598b1ea4da332f15dfb843a2decf Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Sun, 31 Jan 2016 02:17:28 +0800 Subject: [PATCH] Add test for npm shrinkwrap compatibility --- package.json | 1 + test/index.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/package.json b/package.json index 803ae430de..b3a529026b 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "eslint-config-standard": "4.4.0", "eslint-plugin-standard": "1.3.1", "nixt": "0.5.0", + "npm": "3.6.0", "sepia": "2.0.1", "tap-spec": "4.1.1", "tape": "4.4.0", diff --git a/test/index.js b/test/index.js index bb0eff2e01..e47257a21d 100644 --- a/test/index.js +++ b/test/index.js @@ -147,3 +147,19 @@ test('tarballs (is-array-1.0.1.tgz)', function (t) { }, t.end) }) +test('shrinkwrap compatibility', function (t) { + prepare() + fs.writeFileSync('package.json', + JSON.stringify({ dependencies: { rimraf: '*' } }), + 'utf-8') + + install({ input: ['rimraf@2.5.1'], flags: { quiet: true } }) + .then(function () { + var npm = JSON.stringify(require.resolve('npm/bin/npm-cli.js')) + require('child_process').execSync('node ' + npm + ' shrinkwrap') + var wrap = JSON.parse(fs.readFileSync('npm-shrinkwrap.json', 'utf-8')) + t.ok(wrap.dependencies.rimraf.version === '2.5.1', + 'npm shrinkwrap is successful') + t.end() + }, t.end) +})