A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/npm/cli/commit/bdb3c28167f757060474ef2b82c92f3a1f210972 below:

added check for dry-run (#7274) · npm/cli@bdb3c28 · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+32

-8

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+32

-8

lines changed Original file line number Diff line number Diff line change

@@ -75,14 +75,18 @@ class CI extends ArboristWorkspaceCmd {

75 75

)

76 76

}

77 77 78 -

// Only remove node_modules after we've successfully loaded the virtual

79 -

// tree and validated the lockfile

80 -

await this.npm.time('npm-ci:rm', async () => {

81 -

const path = `${where}/node_modules`

82 -

// get the list of entries so we can skip the glob for performance

83 -

const entries = await fs.readdir(path, null).catch(er => [])

84 -

return Promise.all(entries.map(f => fs.rm(`${path}/${f}`, { force: true, recursive: true })))

85 -

})

78 +

const dryRun = this.npm.config.get('dry-run')

79 +

if (!dryRun) {

80 +

// Only remove node_modules after we've successfully loaded the virtual

81 +

// tree and validated the lockfile

82 +

await this.npm.time('npm-ci:rm', async () => {

83 +

const path = `${where}/node_modules`

84 +

// get the list of entries so we can skip the glob for performance

85 +

const entries = await fs.readdir(path, null).catch(er => [])

86 +

return Promise.all(entries.map(f => fs.rm(`${path}/${f}`,

87 +

{ force: true, recursive: true })))

88 +

})

89 +

}

86 90 87 91

await arb.reify(opts)

88 92 Original file line number Diff line number Diff line change

@@ -56,6 +56,26 @@ const abbrev = {

56 56

test: 'test file',

57 57

}

58 58 59 +

t.test('reifies, but doesn\'t remove node_modules because --dry-run', async t => {

60 +

const { npm, joinedOutput } = await loadMockNpm(t, {

61 +

config: {

62 +

'dry-run': true,

63 +

},

64 +

prefixDir: {

65 +

abbrev: abbrev,

66 +

'package.json': JSON.stringify(packageJson),

67 +

'package-lock.json': JSON.stringify(packageLock),

68 +

node_modules: { test: 'test file that will not be removed' },

69 +

},

70 +

})

71 +

await npm.exec('ci', [])

72 +

t.match(joinedOutput(), 'added 1 package, and removed 1 package in')

73 +

const nmTest = path.join(npm.prefix, 'node_modules', 'test')

74 +

t.equal(fs.existsSync(nmTest), true, 'existing node_modules is not removed')

75 +

const nmAbbrev = path.join(npm.prefix, 'node_modules', 'abbrev')

76 +

t.equal(fs.existsSync(nmAbbrev), false, 'does not install abbrev')

77 +

})

78 + 59 79

t.test('reifies, audits, removes node_modules', async t => {

60 80

const { npm, joinedOutput, registry } = await loadMockNpm(t, {

61 81

prefixDir: {

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4