npm-packlist 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +14 -4
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -83,13 +83,23 @@ const npmWalker = Class => class Walker extends Class {
83
83
  opt.path = opt.path || process.cwd()
84
84
  const dirName = path.basename(opt.path)
85
85
  const parentName = path.basename(path.dirname(opt.path))
86
- opt.follow =
87
- dirName === 'node_modules' ||
88
- (parentName === 'node_modules' && /^@/.test(dirName))
86
+
87
+ // only follow links in the root node_modules folder, because if those
88
+ // folders are included, it's because they're bundled, and bundles
89
+ // should include the contents, not the symlinks themselves.
90
+ // This regexp tests to see that we're either a node_modules folder,
91
+ // or a @scope within a node_modules folder, in the root's node_modules
92
+ // hierarchy (ie, not in test/foo/node_modules/ or something).
93
+ const followRe = /^(?:\/node_modules\/(?:@[^\/]+\/[^\/]+|[^\/]+)\/)*\/node_modules(?:\/@[^\/]+)?$/
94
+ const rootPath = opt.parent ? opt.parent.root : opt.path
95
+ const followTestPath = opt.path.replace(/\\/g, '/').substr(rootPath.length)
96
+ opt.follow = followRe.test(followTestPath)
97
+
89
98
  super(opt)
90
99
 
91
100
  // ignore a bunch of things by default at the root level.
92
- // also ignore anything in node_modules, except bundled dependencies
101
+ // also ignore anything in the main project node_modules hierarchy,
102
+ // except bundled dependencies
93
103
  if (!this.parent) {
94
104
  this.bundled = opt.bundled || []
95
105
  this.bundledScopes = Array.from(new Set(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-packlist",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "Get a list of the files to add from a folder into an npm package",
5
5
  "directories": {
6
6
  "test": "test"
@@ -20,7 +20,7 @@
20
20
  "devDependencies": {
21
21
  "mutate-fs": "^2.1.1",
22
22
  "require-inject": "^1.4.4",
23
- "tap": "^14.10.6"
23
+ "tap": "^14.10.7"
24
24
  },
25
25
  "scripts": {
26
26
  "test": "tap",