npm-packlist
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -20,3 +20,3 @@ #!/usr/bin/env node | ||
console.log(sort(packlist.sync({ path: process.cwd() })).join('\n')) | ||
else | ||
else { | ||
dirs.forEach(path => { | ||
@@ -26,1 +26,2 @@ console.log(`> ${path}`) | ||
}) | ||
} |
44
index.js
@@ -32,3 +32,3 @@ 'use strict' | ||
const packageMustHaves = `@(${packageMustHaveFileNames}){,.*[^~$]}` | ||
const packageMustHavesRE = new RegExp(`^(${packageMustHaveFileNames})(\\..*[^~\$])?$`, 'i') | ||
const packageMustHavesRE = new RegExp(`^(${packageMustHaveFileNames})(\\..*[^~$])?$`, 'i') | ||
@@ -79,3 +79,3 @@ const fs = require('fs') | ||
'.gitignore', | ||
packageNecessaryRules | ||
packageNecessaryRules, | ||
] | ||
@@ -85,4 +85,2 @@ | ||
opt.path = opt.path || process.cwd() | ||
const dirName = path.basename(opt.path) | ||
const parentName = path.basename(path.dirname(opt.path)) | ||
@@ -95,3 +93,3 @@ // only follow links in the root node_modules folder, because if those | ||
// 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 | ||
@@ -110,6 +108,6 @@ const followTestPath = opt.path.replace(/\\/g, '/').substr(rootPath.length) | ||
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 { | ||
@@ -136,5 +134,4 @@ this.bundled = [] | ||
// test or something else entirely. | ||
if (this.parent || !entries.includes('package.json')) { | ||
if (this.parent || !entries.includes('package.json')) | ||
return super.onReaddir(entries) | ||
} | ||
@@ -149,5 +146,4 @@ // when the cache has been seeded with the root manifest, | ||
// fall back to filesystem when seeded manifest is invalid | ||
if (!pkg || typeof pkg !== 'object') { | ||
if (!pkg || typeof pkg !== 'object') | ||
return this.readPackageJson(entries) | ||
} | ||
@@ -184,3 +180,3 @@ // feels wonky, but this ensures package bin is _always_ | ||
'!/package-lock.json', | ||
packageMustHaves, | ||
packageMustHaves | ||
) | ||
@@ -243,5 +239,4 @@ return files | ||
results[i] = { negate, fileList } | ||
if (--n === 0) { | ||
if (--n === 0) | ||
processResults(results) | ||
} | ||
} | ||
@@ -284,3 +279,3 @@ const processResults = results => { | ||
const p = this.path.substr(this.root.length + 1) | ||
const pkgre = /^node_modules\/(@[^\/]+\/?[^\/]+|[^\/]+)(\/.*)?$/ | ||
const pkgre = /^node_modules\/(@[^/]+\/?[^/]+|[^/]+)(\/.*)?$/ | ||
const isRoot = !this.parent | ||
@@ -295,3 +290,3 @@ const pkg = isRoot && pkgre.test(entry) ? | ||
/^node_modules($|\/)/i.test(p) ? this.parent.filterEntry( | ||
this.basename + '/' + entry, partial) | ||
this.basename + '/' + entry, partial) | ||
@@ -304,4 +299,4 @@ // if package is bundled, all files included | ||
// 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 | ||
@@ -322,6 +317,6 @@ // only walk top node_modules if we want to bundle something | ||
// 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) | ||
) | ||
@@ -469,8 +464,7 @@ } | ||
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 | ||
@@ -477,0 +471,0 @@ walk.sync = walkSync |
{ | ||
"name": "npm-packlist", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "Get a list of the files to add from a folder into an npm package", | ||
@@ -22,2 +22,7 @@ "directories": { | ||
"devDependencies": { | ||
"eslint": "^7.25.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-promise": "^5.1.0", | ||
"eslint-plugin-standard": "^5.0.0", | ||
"mutate-fs": "^2.1.1", | ||
@@ -28,6 +33,11 @@ "tap": "^15.0.6" | ||
"test": "tap", | ||
"posttest": "npm run lint", | ||
"snap": "tap", | ||
"postsnap": "npm run lintfix", | ||
"preversion": "npm test", | ||
"postversion": "npm publish", | ||
"prepublishOnly": "git push origin --follow-tags" | ||
"prepublishOnly": "git push origin --follow-tags", | ||
"eslint": "eslint", | ||
"lint": "npm run eslint -- index.js bin/index.js \"test/**/*.js\"", | ||
"lintfix": "npm run lint -- --fix" | ||
}, | ||
@@ -39,2 +49,5 @@ "repository": { | ||
"tap": { | ||
"test-env": [ | ||
"LC_ALL=sk" | ||
], | ||
"check-coverage": true, | ||
@@ -41,0 +54,0 @@ "nyc-arg": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23884
7
418