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
diff options
context:
space:
mode:
-rw-r--r--lib/commands/help-search.js4
-rw-r--r--lib/commands/help.js5
-rw-r--r--lib/utils/log-file.js5
3 files changed, 9 insertions, 5 deletions
diff --git a/lib/commands/help-search.js b/lib/commands/help-search.js
index 23b426eaa..488189bbb 100644
--- a/lib/commands/help-search.js
+++ b/lib/commands/help-search.js
@@ -6,6 +6,8 @@ const glob = promisify(require('glob'))
const readFile = promisify(fs.readFile)
const BaseCommand = require('../base-command.js')
+const globify = pattern => pattern.split('\\').join('/')
+
class HelpSearch extends BaseCommand {
static description = 'Search npm help documentation'
static name = 'help-search'
@@ -19,7 +21,7 @@ class HelpSearch extends BaseCommand {
}
const docPath = path.resolve(__dirname, '..', '..', 'docs/content')
- const files = await glob(`${docPath}/*/*.md`)
+ const files = await glob(`${globify(docPath)}/*/*.md`)
const data = await this.readFiles(files)
const results = await this.searchFiles(args, data, files)
const formatted = this.formatResults(args, results)
diff --git a/lib/commands/help.js b/lib/commands/help.js
index d31b3ca69..e7d6395a1 100644
--- a/lib/commands/help.js
+++ b/lib/commands/help.js
@@ -5,6 +5,7 @@ const { promisify } = require('util')
const glob = promisify(require('glob'))
const localeCompare = require('@isaacs/string-locale-compare')('en')
+const globify = pattern => pattern.split('\\').join('/')
const BaseCommand = require('../base-command.js')
// Strips out the number from foo.7 or foo.7. or foo.7.tgz
@@ -26,7 +27,7 @@ class Help extends BaseCommand {
return []
}
const g = path.resolve(__dirname, '../../man/man[0-9]/*.[0-9]')
- const files = await glob(g)
+ const files = await glob(globify(g))
return Object.keys(files.reduce(function (acc, file) {
file = path.basename(file).replace(/\.[0-9]+$/, '')
@@ -61,7 +62,7 @@ class Help extends BaseCommand {
const manroot = path.resolve(__dirname, '..', '..', 'man')
// find either section.n or npm-section.n
const f = `${manroot}/${manSearch}/?(npm-)${section}.[0-9]*`
- let mans = await glob(f)
+ let mans = await glob(globify(f))
mans = mans.sort((a, b) => {
// Prefer the page with an npm prefix, if there's only one.
const aHasPrefix = manNpmPrefixRegex.test(a)
diff --git a/lib/utils/log-file.js b/lib/utils/log-file.js
index 282c72700..9cf6513be 100644
--- a/lib/utils/log-file.js
+++ b/lib/utils/log-file.js
@@ -9,6 +9,7 @@ const fs = require('@npmcli/fs')
const log = require('./log-shim')
const padZero = (n, length) => n.toString().padStart(length.toString().length, '0')
+const globify = pattern => pattern.split('\\').join('/')
const _logHandler = Symbol('logHandler')
const _formatLogItem = Symbol('formatLogItem')
@@ -225,7 +226,7 @@ class LogFiles {
)
// Always ignore the currently written files
- const files = await glob(logGlob, { ignore: this.#files })
+ const files = await glob(globify(logGlob), { ignore: this.#files.map(globify) })
const toDelete = files.length - this.#logsMax
if (toDelete <= 0) {
@@ -236,7 +237,7 @@ class LogFiles {
for (const file of files.slice(0, toDelete)) {
try {
- await rimraf(file)
+ await rimraf(file, { glob: false })
} catch (e) {
log.silly('logfile', 'error removing log file', file, e)
}