diff options
author | Gar <gar+gh@danger.computer> | 2022-02-08 17:59:24 +0300 |
---|---|---|
committer | Gar <wraithgar@github.com> | 2022-02-08 22:23:24 +0300 |
commit | e631faf7b5f414c233d723ee11413264532b37de (patch) | |
tree | ba725e905e89fde588b0ac6e6ed22ffd443faf90 /workspaces/arborist | |
parent | fb6e2ddf942bacf5ae745d16c2d57f3836dce75a (diff) |
fix(arborist): save bundleDependencies to package.json when reifying
Diffstat (limited to 'workspaces/arborist')
-rw-r--r-- | workspaces/arborist/lib/arborist/reify.js | 5 | ||||
-rw-r--r-- | workspaces/arborist/tap-snapshots/test/arborist/reify.js.test.cjs | 4 | ||||
-rw-r--r-- | workspaces/arborist/test/arborist/reify.js | 11 |
3 files changed, 20 insertions, 0 deletions
diff --git a/workspaces/arborist/lib/arborist/reify.js b/workspaces/arborist/lib/arborist/reify.js index 45ef93985..91507fd79 100644 --- a/workspaces/arborist/lib/arborist/reify.js +++ b/workspaces/arborist/lib/arborist/reify.js @@ -1369,6 +1369,10 @@ module.exports = cls => class Reifier extends cls { devDependencies = {}, optionalDependencies = {}, peerDependencies = {}, + // bundleDependencies is not required by PackageJson like the other fields here + // PackageJson also doesn't omit an empty array for this field so defaulting this + // to an empty array would add that field to every package.json file. + bundleDependencies, } = tree.package pkgJson.update({ @@ -1376,6 +1380,7 @@ module.exports = cls => class Reifier extends cls { devDependencies, optionalDependencies, peerDependencies, + bundleDependencies, }) await pkgJson.save() } diff --git a/workspaces/arborist/tap-snapshots/test/arborist/reify.js.test.cjs b/workspaces/arborist/tap-snapshots/test/arborist/reify.js.test.cjs index 6d38d724d..ffd568c68 100644 --- a/workspaces/arborist/tap-snapshots/test/arborist/reify.js.test.cjs +++ b/workspaces/arborist/tap-snapshots/test/arborist/reify.js.test.cjs @@ -33164,6 +33164,10 @@ exports[`test/arborist/reify.js TAP save-prod, with optional > must match snapsh {"dependencies":{"abbrev":"^1.1.1"}} ` +exports[`test/arborist/reify.js TAP saveBundle > must match snapshot 1`] = ` +{"dependencies":{"abbrev":"^1.1.1"},"bundleDependencies":["abbrev"]} +` + exports[`test/arborist/reify.js TAP saving the ideal tree save some stuff > lock after save 1`] = ` Object { "dependencies": Object { diff --git a/workspaces/arborist/test/arborist/reify.js b/workspaces/arborist/test/arborist/reify.js index caa15f59f..7fb1f1f2b 100644 --- a/workspaces/arborist/test/arborist/reify.js +++ b/workspaces/arborist/test/arborist/reify.js @@ -1783,6 +1783,17 @@ t.test('save-prod, with optional', async t => { t.matchSnapshot(fs.readFileSync(path + '/package.json', 'utf8')) }) +t.test('saveBundle', async t => { + const path = t.testdir({ + 'package.json': JSON.stringify({ + dependencies: { abbrev: '*' }, + }), + }) + const arb = newArb({ path }) + await arb.reify({ add: ['abbrev'], saveType: 'prod', saveBundle: true }) + t.matchSnapshot(fs.readFileSync(path + '/package.json', 'utf8')) +}) + t.test('no saveType: dev w/ compatible peer', async t => { const path = t.testdir({ 'package.json': JSON.stringify({ |