From 4f924651ccefd1e88de9211f80dd4ab74bd91a83 Mon Sep 17 00:00:00 2001 From: Darcy Clarke Date: Wed, 11 Nov 2020 19:10:01 -0500 Subject: [PATCH] fix: pass flatOptions through to Arborist.reify in npm ci Fixes: #2017 --- lib/ci.js | 2 +- test/lib/ci.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/ci.js b/lib/ci.js index a72e1c0cffba6..a1632e7e98064 100644 --- a/lib/ci.js +++ b/lib/ci.js @@ -34,7 +34,7 @@ const ci = async () => { rimraf(`${where}/node_modules/*`, { glob: { dot: true, nosort: true, silent: true } }), ]) // npm ci should never modify the lockfile or package.json - await arb.reify({ save: false }) + await arb.reify({ ...npm.flatOptions, save: false }) reifyOutput(arb) } diff --git a/test/lib/ci.js b/test/lib/ci.js index 645fc6aed97e4..43ad2783b02d7 100644 --- a/test/lib/ci.js +++ b/test/lib/ci.js @@ -42,6 +42,25 @@ test('should use Arborist', (t) => { }) }) +test('should pass flatOptions to Arborist.reify', (t) => { + const ci = requireInject('../../lib/ci.js', { + '../../lib/npm.js': { + prefix: 'foo', + flatOptions: { + production: true + } + }, + '@npmcli/arborist': function () { + this.loadVirtual = () => Promise.resolve(true) + this.reify = async (options) => { + t.equal(options.production, true, 'should pass flatOptions to Arborist.reify') + t.end() + } + } + }) + ci(null, () => {}) +}) + test('should throw if package-lock.json or npm-shrinkwrap missing', (t) => { const testDir = t.testdir({ 'index.js': 'some contents',