Socket
Socket
Sign inDemoInstall

npm-packlist

Package Overview
Dependencies
12
Maintainers
6
Versions
62
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.3 to 5.0.4

51

lib/index.js

@@ -36,2 +36,29 @@ 'use strict'

const readOutOfTreeIgnoreFiles = (root, rel, result = '') => {
for (const file of ['.gitignore', '.npmignore']) {
try {
const ignoreContent = fs.readFileSync(path.join(root, file), { encoding: 'utf8' })
result += ignoreContent + '\n'
} catch (err) {
// we ignore ENOENT errors completely because we don't care if the file doesn't exist
// but we throw everything else because failing to read a file that does exist is
// something that the user likely wants to know about. we don't need to test this.
/* istanbul ignore next */
if (err.code !== 'ENOENT') {
throw err
}
}
}
if (!rel) {
return result
}
const firstRel = rel.split(path.sep)[0]
const newRoot = path.join(root, firstRel)
const newRel = path.relative(newRoot, path.join(root, rel))
return readOutOfTreeIgnoreFiles(newRoot, newRel, result)
}
const pathHasPkg = (input) => {

@@ -123,5 +150,27 @@ if (!input.startsWith('node_modules/')) {

.map(f => f.split('/')[0])))
const rules = defaultRules.join('\n') + '\n'
this.packageJsonCache = this.parent ? this.parent.packageJsonCache
: (opt.packageJsonCache || new Map())
let rules = defaultRules.join('\n') + '\n'
if (opt.prefix && opt.workspaces) {
const gPath = globify(opt.path)
const gPrefix = globify(opt.prefix)
const gWorkspaces = opt.workspaces.map((ws) => globify(ws))
// if opt.path and opt.prefix are not the same directory, and opt.workspaces has opt.path
// in it, then we know that opt.path is a workspace directory. in order to not drop ignore
// rules from directories between the workspace root (opt.prefix) and the workspace itself
// (opt.path), we need to find and read those now
/* istanbul ignore else */
if (gPath !== gPrefix && gWorkspaces.includes(gPath)) {
// relpath is the relative path between the prefix and the parent of opt.path
// we use the parent because ignore-walk will read the files in opt.path already
const relpath = path.relative(opt.prefix, path.dirname(opt.path))
rules += readOutOfTreeIgnoreFiles(opt.prefix, relpath)
} else if (gPath === gPrefix) {
// on the other hand, if the path and the prefix are the same, then we ignore workspaces
// so that we don't pack workspaces inside of a root project
rules += opt.workspaces.map((ws) => globify(path.relative(opt.path, ws))).join('\n')
}
}
super.onReadIgnoreFile(rootBuiltinRules, rules, _ => _)

@@ -128,0 +177,0 @@ } else {

6

package.json
{
"name": "npm-packlist",
"version": "5.0.3",
"version": "5.0.4",
"description": "Get a list of the files to add from a folder into an npm package",

@@ -23,3 +23,3 @@ "directories": {

"@npmcli/eslint-config": "^3.0.1",
"@npmcli/template-oss": "3.4.2",
"@npmcli/template-oss": "3.5.0",
"mutate-fs": "^2.1.1",

@@ -60,4 +60,4 @@ "tap": "^16.0.1"

"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "3.4.2"
"version": "3.5.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc