Skip to content

Commit 05c3c88

Browse files
committed
Expose defaultIgnore from globs helpers and use them
1 parent 8a86f23 commit 05c3c88

File tree

3 files changed

+48
-42
lines changed

3 files changed

+48
-42
lines changed

registry/lib/fs.js

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,11 @@
22

33
const { freeze: ObjectFreeze } = Object
44

5-
const { getGlobMatcher } = /*@__PURE__*/ require('./globs')
5+
const { defaultIgnore, getGlobMatcher } = /*@__PURE__*/ require('./globs')
66
const { naturalCompare } = /*@__PURE__*/ require('./sorts')
77
const { pathLikeToString } = /*@__PURE__*/ require('./path')
88
const { stripBom } = /*@__PURE__*/ require('./strings')
99

10-
const defaultIgnore = ObjectFreeze([
11-
// Most of these ignored files can be included specifically if included in the
12-
// files globs. Exceptions to this are:
13-
// https://docs.npmjs.com/cli/v10/configuring-npm/package-json#files
14-
// These can NOT be included.
15-
// https://github.com/npm/npm-packlist/blob/v10.0.0/lib/index.js#L280
16-
'**/.git',
17-
'**/.npmrc',
18-
// '**/bun.lockb?',
19-
// '**/node_modules',
20-
// '**/package-lock.json',
21-
// '**/pnpm-lock.ya?ml',
22-
// '**/yarn.lock',
23-
// Include npm-packlist defaults:
24-
// https://github.com/npm/npm-packlist/blob/v10.0.0/lib/index.js#L15-L38
25-
'**/.DS_Store',
26-
'**/.gitignore',
27-
'**/.hg',
28-
'**/.lock-wscript',
29-
'**/.npmignore',
30-
'**/.svn',
31-
'**/.wafpickle-*',
32-
'**/.*.swp',
33-
'**/._*/**',
34-
'**/archived-packages/**',
35-
'**/build/config.gypi',
36-
'**/CVS',
37-
'**/npm-debug.log',
38-
'**/*.orig',
39-
// Inline generic .gitignore entries from the socket-registry repository root.
40-
'**/.env',
41-
'**/.eslintcache',
42-
'**/.nvm',
43-
'**/.tap',
44-
'**/.tapci.yaml',
45-
'**/.vscode',
46-
'**/*.tsbuildinfo',
47-
'**/Thumbs.db'
48-
])
49-
5010
const defaultRemoveOptions = ObjectFreeze({
5111
__proto__: null,
5212
force: true,

registry/lib/globs.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ declare type GlobOptions = Remap<
144144
}
145145
>
146146
declare const Globs: {
147+
defaultIgnore: readonly string[]
147148
getGlobMatcher: (
148149
glob: string | string[] | readonly string[],
149150
options?: object | undefined

registry/lib/globs.js

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,49 @@
11
'use strict'
22

3+
const { freeze: ObjectFreeze } = Object
4+
5+
const defaultIgnore = ObjectFreeze([
6+
// Most of these ignored files can be included specifically if included in the
7+
// files globs. Exceptions to this are:
8+
// https://docs.npmjs.com/cli/v10/configuring-npm/package-json#files
9+
// These can NOT be included.
10+
// https://github.com/npm/npm-packlist/blob/v10.0.0/lib/index.js#L280
11+
'**/.git',
12+
'**/.npmrc',
13+
// '**/bun.lockb?',
14+
'**/node_modules',
15+
// '**/package-lock.json',
16+
// '**/pnpm-lock.ya?ml',
17+
// '**/yarn.lock',
18+
// Include npm-packlist defaults:
19+
// https://github.com/npm/npm-packlist/blob/v10.0.0/lib/index.js#L15-L38
20+
'**/.DS_Store',
21+
'**/.gitignore',
22+
'**/.hg',
23+
'**/.lock-wscript',
24+
'**/.npmignore',
25+
'**/.svn',
26+
'**/.wafpickle-*',
27+
'**/.*.swp',
28+
'**/._*/**',
29+
'**/archived-packages/**',
30+
'**/build/config.gypi',
31+
'**/CVS',
32+
'**/npm-debug.log',
33+
'**/*.orig',
34+
// Inline generic socket-registry .gitignore entries.
35+
'**/.env',
36+
'**/.eslintcache',
37+
'**/.nvm',
38+
'**/.tap',
39+
'**/.tapci.yaml',
40+
'**/.vscode',
41+
'**/*.tsbuildinfo',
42+
'**/Thumbs.db',
43+
// Inline additional ignores.
44+
'**/bower_components'
45+
])
46+
347
let _picomatch
448
/*@__NO_SIDE_EFFECTS__*/
549
function getPicomatch() {
@@ -28,7 +72,7 @@ function globStreamLicenses(dirname, options) {
2872
...globOptions
2973
} = { __proto__: null, ...options }
3074
const ignore = [
31-
...(Array.isArray(ignoreOpt) ? ignoreOpt : []),
75+
...(Array.isArray(ignoreOpt) ? ignoreOpt : defaultIgnore),
3276
'**/*.{cjs,cts,js,json,mjs,mts,ts}'
3377
]
3478
if (ignoreOriginals) {
@@ -74,6 +118,7 @@ function getGlobMatcher(glob, options) {
74118
}
75119

76120
module.exports = {
121+
defaultIgnore,
77122
getGlobMatcher,
78123
globStreamLicenses
79124
}

0 commit comments

Comments
 (0)