Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDanielle Church <dani.church@gmail.com>2021-03-24 22:17:58 +0300
committerRuy Adorno <ruyadorno@hotmail.com>2021-03-26 00:30:34 +0300
commit95ba87622e00d68270eda9e071b19737718fca16 (patch)
treee54bcd39badf77ba97c8c52ad438abffcedac690 /test
parent2b3d1f983b4c75adfcff284573841a71f11f1146 (diff)
Fix manNumberRegex in help.js
The current regex will match any .[0-9]. pattern anywhere in the path, which will give incorrect results if npm is installed to a path like .../node-v14.5.5/... This change restricts it to only the last path element. PR-URL: https://github.com/npm/cli/pull/2949 Credit: @dmchurch Close: #2949 Reviewed-by: @wraithgar
Diffstat (limited to 'test')
-rw-r--r--test/lib/help.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/lib/help.js b/test/lib/help.js
index ccf13a7e4..b5fe297b5 100644
--- a/test/lib/help.js
+++ b/test/lib/help.js
@@ -340,3 +340,26 @@ test('npm help - man viewer propagates errors', t => {
t.end()
})
})
+
+test('npm help with complex installation path finds proper help file', t => {
+ npmConfig.viewer = 'browser'
+ globResult = [
+ 'C:/Program Files/node-v14.15.5-win-x64/node_modules/npm/man/man1/npm-install.1',
+ // glob always returns forward slashes, even on Windows
+ ]
+
+ t.teardown(() => {
+ npmConfig.viewer = undefined
+ globResult = globDefaults
+ spawnBin = null
+ spawnArgs = null
+ })
+
+ return help.exec(['1', 'install'], (err) => {
+ if (err)
+ throw err
+
+ t.match(openUrlArg, /commands(\/|\\)npm-install.html$/, 'attempts to open the correct url')
+ t.end()
+ })
+})