diff options
author | Rebecca Turner <me@re-becca.org> | 2018-02-15 04:14:26 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2018-02-20 06:05:46 +0300 |
commit | 8279515903cfa3026cf7096189485cdf29f74a8f (patch) | |
tree | 1df8321ee825775208e6f128f2fb8f79af137a6b /test | |
parent | 857dab03f2d58586b45d41d3e5af0fb2d4e824d0 (diff) |
install: Handle packages without install metadata gracefully
Currently the only way to get these is to use yarn.
What this means is that we:
Leave them untouched if you didn't as us to do a full install.
Upgrade their metadata if you DID ask us to do a full install.
While: Not messing with a lock file that only has version fields except for
modules we touched.
Diffstat (limited to 'test')
-rw-r--r-- | test/tap/bundled-dependencies-no-pkgjson.js | 55 | ||||
-rw-r--r-- | test/tap/override-bundled.js | 6 | ||||
-rw-r--r-- | test/tap/unit-deps-earliestInstallable.js | 5 |
3 files changed, 5 insertions, 61 deletions
diff --git a/test/tap/bundled-dependencies-no-pkgjson.js b/test/tap/bundled-dependencies-no-pkgjson.js deleted file mode 100644 index a7056408a..000000000 --- a/test/tap/bundled-dependencies-no-pkgjson.js +++ /dev/null @@ -1,55 +0,0 @@ -var test = require('tap').test -var path = require('path') -var fs = require('graceful-fs') - -var mkdirp = require('mkdirp') -var rimraf = require('rimraf') -var common = require('../common-tap.js') - -var dir = path.resolve(__dirname, 'bundled-dependencies-no-pkgjson') -var pkg = path.resolve(dir, 'pkg-with-bundled-dep') -var dep = path.resolve(pkg, 'node_modules', 'a-bundled-dep') - -var pkgJson = JSON.stringify({ - name: 'pkg-with-bundled-dep', - version: '1.0.0', - dependencies: { - }, - bundledDependencies: [ - 'a-bundled-dep' - ] -}, null, 2) + '\n' -var packed - -test('setup', function (t) { - rimraf.sync(dir) - mkdirp.sync(path.join(dir, 'node_modules')) - mkdirp.sync(dep) - - fs.writeFileSync(path.resolve(pkg, 'package.json'), pkgJson) - fs.writeFileSync(path.resolve(dep, 'index.js'), '') - common.npm(['pack', pkg], {cwd: dir}, function (err, code, stdout, stderr) { - if (err) throw err - t.is(code, 0, 'packed ok') - packed = stdout.trim() - t.comment(stderr) - t.end() - }) -}) - -test('proper error on bundled dep with no package.json', function (t) { - t.plan(2) - var npmArgs = ['install', packed] - - common.npm(npmArgs, { cwd: dir }, function (err, code, stdout, stderr) { - if (err) throw err - t.notEqual(code, 0, 'npm ended in error') - t.like(stderr, /ENOENT/, 'ENOENT should be in stderr') - t.end() - }) -}) - -test('cleanup', function (t) { - rimraf.sync(dir) - t.end() -}) diff --git a/test/tap/override-bundled.js b/test/tap/override-bundled.js index 6cbab620d..493ebf4a5 100644 --- a/test/tap/override-bundled.js +++ b/test/tap/override-bundled.js @@ -15,7 +15,7 @@ var testtgz = testmod + '-1.0.0.tgz' var bundleupdatesrc = path.resolve(testmod, 'bundle-update') var bundleupdatetgz = bundleupdatesrc + '-1.0.0.tgz' var bundleupdateNEW = path.resolve(bundleupdatesrc, 'NEW') -var bundleupdateNEWpostinstall = path.resolve(testdir, 'node_modules', 'top-test', 'node_modules', 'bundle-update', 'NEW') +var bundleupdateNEWpostinstall = path.resolve(testdir, 'node_modules', 'bundle-update', 'NEW') var bundleupdatebad = path.resolve(testmod, 'node_modules', 'bundle-update') var bundlekeepsrc = path.resolve(testmod, 'bundle-keep') @@ -34,8 +34,7 @@ var bundledeepupdatesrc = path.resolve(testmod, 'bundle-deep-update') var bundledeepupdatetgz = bundledeepupdatesrc + '-1.0.0.tgz' var bundledeepupdate = path.resolve(bundledeep, 'node_modules', 'bundle-deep-update') var bundledeepupdateNEW = path.resolve(bundledeepupdatesrc, 'NEW') -var bundledeepupdateNEWpostinstall = path.resolve(testdir, 'node_modules', 'top-test', - 'node_modules', 'bundle-deep', 'node_modules', 'bundle-deep-update', 'NEW') +var bundledeepupdateNEWpostinstall = path.resolve(testdir, 'node_modules', 'bundle-deep-update', 'NEW') var testjson = { dependencies: {'top-test': 'file:' + testtgz} @@ -56,7 +55,6 @@ var bundlejson = { name: 'bundle-update', version: '1.0.0', files: ['OLD', 'NEW'] - } var bundlekeepjson = { diff --git a/test/tap/unit-deps-earliestInstallable.js b/test/tap/unit-deps-earliestInstallable.js index 538cfe6c0..8c5ca06ad 100644 --- a/test/tap/unit-deps-earliestInstallable.js +++ b/test/tap/unit-deps-earliestInstallable.js @@ -2,6 +2,7 @@ var test = require('tap').test var requireInject = require('require-inject') var npa = require('npm-package-arg') +var log = require('npmlog') // we're just mocking to avoid having to call `npm.load` var deps = requireInject('../../lib/install/deps.js', { @@ -66,7 +67,7 @@ test('earliestInstallable should consider devDependencies', function (t) { dep2a.parent = dep1 dep2.parent = pkg - var earliest = earliestInstallable(dep1, dep1, dep2a.package) + var earliest = earliestInstallable(dep1, dep1, dep2a.package, log) t.isDeeply(earliest, dep1, 'should hoist package when an incompatible devDependency is present') t.end() }) @@ -107,7 +108,7 @@ test('earliestInstallable should reuse shared prod/dev deps when they are identi dep1.parent = pkg dep2.parent = pkg - var earliest = earliestInstallable(dep1, dep1, dep2.package) + var earliest = earliestInstallable(dep1, dep1, dep2.package, log) t.isDeeply(earliest, pkg, 'should reuse identical shared dev/prod deps when installing both') t.end() }) |