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

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/npm-packlist/index.js')
-rw-r--r--deps/npm/node_modules/npm-packlist/index.js47
1 files changed, 20 insertions, 27 deletions
diff --git a/deps/npm/node_modules/npm-packlist/index.js b/deps/npm/node_modules/npm-packlist/index.js
index 8f62983e6f6..f498fa008ce 100644
--- a/deps/npm/node_modules/npm-packlist/index.js
+++ b/deps/npm/node_modules/npm-packlist/index.js
@@ -26,11 +26,10 @@ const normalizePackageBin = require('npm-normalize-package-bin')
// localized documentation and other use cases. Adding a `/` to
// these rules, while tempting and arguably more "correct", is a
// significant change that will break existing use cases.
-const packageMustHaveFileNames =
- 'readme|copying|license|licence|notice|changes|changelog|history'
+const packageMustHaveFileNames = 'readme|copying|license|licence'
const packageMustHaves = `@(${packageMustHaveFileNames}){,.*[^~$]}`
-const packageMustHavesRE = new RegExp(`^(${packageMustHaveFileNames})(\\..*[^~\$])?$`, 'i')
+const packageMustHavesRE = new RegExp(`^(${packageMustHaveFileNames})(\\..*[^~$])?$`, 'i')
const fs = require('fs')
const glob = require('glob')
@@ -76,13 +75,11 @@ const npmWalker = Class => class Walker extends Class {
'package.json',
'.npmignore',
'.gitignore',
- packageNecessaryRules
+ packageNecessaryRules,
]
opt.includeEmpty = false
opt.path = opt.path || process.cwd()
- const dirName = path.basename(opt.path)
- const parentName = path.basename(path.dirname(opt.path))
// only follow links in the root node_modules folder, because if those
// folders are included, it's because they're bundled, and bundles
@@ -90,7 +87,7 @@ const npmWalker = Class => class Walker extends Class {
// This regexp tests to see that we're either a node_modules folder,
// or a @scope within a node_modules folder, in the root's node_modules
// hierarchy (ie, not in test/foo/node_modules/ or something).
- const followRe = /^(?:\/node_modules\/(?:@[^\/]+\/[^\/]+|[^\/]+)\/)*\/node_modules(?:\/@[^\/]+)?$/
+ const followRe = /^(?:\/node_modules\/(?:@[^/]+\/[^/]+|[^/]+)\/)*\/node_modules(?:\/@[^/]+)?$/
const rootPath = opt.parent ? opt.parent.root : opt.path
const followTestPath = opt.path.replace(/\\/g, '/').substr(rootPath.length)
opt.follow = followRe.test(followTestPath)
@@ -104,10 +101,10 @@ const npmWalker = Class => class Walker extends Class {
this.bundled = opt.bundled || []
this.bundledScopes = Array.from(new Set(
this.bundled.filter(f => /^@/.test(f))
- .map(f => f.split('/')[0])))
+ .map(f => f.split('/')[0])))
const rules = defaultRules.join('\n') + '\n'
this.packageJsonCache = opt.packageJsonCache || new Map()
- super.onReadIgnoreFile(rootBuiltinRules, rules, _=>_)
+ super.onReadIgnoreFile(rootBuiltinRules, rules, _ => _)
} else {
this.bundled = []
this.bundledScopes = []
@@ -129,9 +126,8 @@ const npmWalker = Class => class Walker extends Class {
// to be in the state the user wants to include them, and
// a package.json somewhere else might be a template or
// test or something else entirely.
- if (this.parent || !entries.includes('package.json')) {
+ if (this.parent || !entries.includes('package.json'))
return super.onReaddir(entries)
- }
// when the cache has been seeded with the root manifest,
// we must respect that (it may differ from the filesystem)
@@ -141,9 +137,8 @@ const npmWalker = Class => class Walker extends Class {
const pkg = this.packageJsonCache.get(ig)
// fall back to filesystem when seeded manifest is invalid
- if (!pkg || typeof pkg !== 'object') {
+ if (!pkg || typeof pkg !== 'object')
return this.readPackageJson(entries)
- }
// feels wonky, but this ensures package bin is _always_
// normalized, as well as guarding against invalid JSON
@@ -175,7 +170,7 @@ const npmWalker = Class => class Walker extends Class {
'/package.json',
'/npm-shrinkwrap.json',
'!/package-lock.json',
- packageMustHaves,
+ packageMustHaves
)
return files
}
@@ -233,9 +228,8 @@ const npmWalker = Class => class Walker extends Class {
return this.emit('error', er)
results[i] = { negate, fileList }
- if (--n === 0) {
+ if (--n === 0)
processResults(results)
- }
}
const processResults = results => {
for (const {negate, fileList} of results) {
@@ -273,7 +267,7 @@ const npmWalker = Class => class Walker extends Class {
filterEntry (entry, partial) {
// get the partial path from the root of the walk
const p = this.path.substr(this.root.length + 1)
- const pkgre = /^node_modules\/(@[^\/]+\/?[^\/]+|[^\/]+)(\/.*)?$/
+ const pkgre = /^node_modules\/(@[^/]+\/?[^/]+|[^/]+)(\/.*)?$/
const isRoot = !this.parent
const pkg = isRoot && pkgre.test(entry) ?
entry.replace(pkgre, '$1') : null
@@ -283,7 +277,7 @@ const npmWalker = Class => class Walker extends Class {
return (
// if we're in a bundled package, check with the parent.
/^node_modules($|\/)/i.test(p) ? this.parent.filterEntry(
- this.basename + '/' + entry, partial)
+ this.basename + '/' + entry, partial)
// if package is bundled, all files included
// also include @scope dirs for bundled scoped deps
@@ -291,8 +285,8 @@ const npmWalker = Class => class Walker extends Class {
// However, this only matters if we're in the root.
// node_modules folders elsewhere, like lib/node_modules,
// should be included normally unless ignored.
- : pkg ? -1 !== this.bundled.indexOf(pkg) ||
- -1 !== this.bundledScopes.indexOf(pkg)
+ : pkg ? this.bundled.indexOf(pkg) !== -1 ||
+ this.bundledScopes.indexOf(pkg) !== -1
// only walk top node_modules if we want to bundle something
: rootNM ? !!this.bundled.length
@@ -308,10 +302,10 @@ const npmWalker = Class => class Walker extends Class {
? true
// package-lock never included
- : isRoot && entry === 'package-lock.json' ? false
+ : isRoot && entry === 'package-lock.json' ? false
- // otherwise, follow ignore-walk's logic
- : super.filterEntry(entry, partial)
+ // otherwise, follow ignore-walk's logic
+ : super.filterEntry(entry, partial)
)
}
@@ -454,12 +448,11 @@ const sort = (a, b) => {
const basea = path.basename(a).toLowerCase()
const baseb = path.basename(b).toLowerCase()
- return exta.localeCompare(extb) ||
- basea.localeCompare(baseb) ||
- a.localeCompare(b)
+ return exta.localeCompare(extb, 'en') ||
+ basea.localeCompare(baseb, 'en') ||
+ a.localeCompare(b, 'en')
}
-
module.exports = walk
walk.sync = walkSync
walk.Walker = Walker