Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Feb 7, 2023
1 parent f4c8c62 commit 99457f1
Show file tree
Hide file tree
Showing 36 changed files with 4,425 additions and 58 deletions.
9 changes: 9 additions & 0 deletions node_modules/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
!/@npmcli/git
!/@npmcli/installed-package-contents
!/@npmcli/map-workspaces
!/@npmcli/map-workspaces/node_modules/
/@npmcli/map-workspaces/node_modules/*
!/@npmcli/map-workspaces/node_modules/minimatch
!/@npmcli/metavuln-calculator
!/@npmcli/name-from-folder
!/@npmcli/node-gyp
Expand Down Expand Up @@ -89,6 +92,9 @@
!/function-bind
!/gauge
!/glob
!/glob/node_modules/
/glob/node_modules/*
!/glob/node_modules/minimatch
!/graceful-fs
!/has-flag
!/has-unicode
Expand All @@ -101,6 +107,9 @@
!/iconv-lite
!/ieee754
!/ignore-walk
!/ignore-walk/node_modules/
/ignore-walk/node_modules/*
!/ignore-walk/node_modules/minimatch
!/imurmurhash
!/indent-string
!/infer-owner
Expand Down
15 changes: 15 additions & 0 deletions node_modules/@npmcli/map-workspaces/node_modules/minimatch/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
The ISC License

Copyright (c) 2011-2023 Isaac Z. Schlueter and Contributors

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ minimatch.match = (list, pattern, options = {}) => {

// replace stuff like \* with *
const globUnescape = s => s.replace(/\\(.)/g, '$1')
const charUnescape = s => s.replace(/\\([^-\]])/g, '$1')
const regExpEscape = s => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
const braExpEscape = s => s.replace(/[[\]\\]/g, '\\$&')

class Minimatch {
constructor (pattern, options) {
Expand Down Expand Up @@ -425,7 +427,7 @@ class Minimatch {
if (pattern === '') return ''

let re = ''
let hasMagic = !!options.nocase
let hasMagic = false
let escaping = false
// ? => one single character
const patternListStack = []
Expand All @@ -438,11 +440,23 @@ class Minimatch {
let pl
let sp
// . and .. never match anything that doesn't start with .,
// even when options.dot is set.
const patternStart = pattern.charAt(0) === '.' ? '' // anything
// not (start or / followed by . or .. followed by / or end)
: options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))'
: '(?!\\.)'
// even when options.dot is set. However, if the pattern
// starts with ., then traversal patterns can match.
let dotTravAllowed = pattern.charAt(0) === '.'
let dotFileAllowed = options.dot || dotTravAllowed
const patternStart = () =>
dotTravAllowed
? ''
: dotFileAllowed
? '(?!(?:^|\\/)\\.{1,2}(?:$|\\/))'
: '(?!\\.)'
const subPatternStart = (p) =>
p.charAt(0) === '.'
? ''
: options.dot
? '(?!(?:^|\\/)\\.{1,2}(?:$|\\/))'
: '(?!\\.)'


const clearStateChar = () => {
if (stateChar) {
Expand Down Expand Up @@ -492,6 +506,11 @@ class Minimatch {
}

case '\\':
if (inClass && pattern.charAt(i + 1) === '-') {
re += c
continue
}

clearStateChar()
escaping = true
continue
Expand Down Expand Up @@ -526,7 +545,7 @@ class Minimatch {
if (options.noext) clearStateChar()
continue

case '(':
case '(': {
if (inClass) {
re += '('
continue
Expand All @@ -537,46 +556,64 @@ class Minimatch {
continue
}

patternListStack.push({
const plEntry = {
type: stateChar,
start: i - 1,
reStart: re.length,
open: plTypes[stateChar].open,
close: plTypes[stateChar].close
})
// negation is (?:(?!js)[^/]*)
re += stateChar === '!' ? '(?:(?!(?:' : '(?:'
close: plTypes[stateChar].close,
}
this.debug(this.pattern, '\t', plEntry)
patternListStack.push(plEntry)
// negation is (?:(?!(?:js)(?:<rest>))[^/]*)
re += plEntry.open
// next entry starts with a dot maybe?
if (plEntry.start === 0 && plEntry.type !== '!') {
dotTravAllowed = true
re += subPatternStart(pattern.slice(i + 1))
}
this.debug('plType %j %j', stateChar, re)
stateChar = false
continue
continue
}

case ')':
if (inClass || !patternListStack.length) {
case ')': {
const plEntry = patternListStack[patternListStack.length - 1]
if (inClass || !plEntry) {
re += '\\)'
continue
}
patternListStack.pop()

// closing an extglob
clearStateChar()
hasMagic = true
pl = patternListStack.pop()
pl = plEntry
// negation is (?:(?!js)[^/]*)
// The others are (?:<pattern>)<type>
re += pl.close
if (pl.type === '!') {
negativeLists.push(pl)
negativeLists.push(Object.assign(pl, { reEnd: re.length }))
}
pl.reEnd = re.length
continue
continue
}

case '|':
if (inClass || !patternListStack.length) {
case '|': {
const plEntry = patternListStack[patternListStack.length - 1]
if (inClass || !plEntry) {
re += '\\|'
continue
}

clearStateChar()
re += '|'
continue
// next subpattern can start with a dot?
if (plEntry.start === 0 && plEntry.type !== '!') {
dotTravAllowed = true
re += subPatternStart(pattern.slice(i + 1))
}
continue
}

// these are mostly the same in regexp and glob
case '[':
Expand Down Expand Up @@ -604,8 +641,6 @@ class Minimatch {
continue
}

// handle the case where we left a class open.
// "[z-a]" is valid, equivalent to "\[z-a\]"
// split where the last [ was, make sure we don't have
// an invalid re. if so, re-walk the contents of the
// would-be class to re-translate any characters that
Expand All @@ -615,20 +650,16 @@ class Minimatch {
// to do safely. For now, this is safe and works.
cs = pattern.substring(classStart + 1, i)
try {
RegExp('[' + cs + ']')
RegExp('[' + braExpEscape(charUnescape(cs)) + ']')
// looks good, finish up the class.
re += c
} catch (er) {
// not a valid class!
sp = this.parse(cs, SUBPARSE)
re = re.substring(0, reClassStart) + '\\[' + sp[0] + '\\]'
hasMagic = hasMagic || sp[1]
inClass = false
continue
// out of order ranges in JS are errors, but in glob syntax,
// they're just a range that matches nothing.
re = re.substring(0, reClassStart) + '(?:$.)' // match nothing ever
}

// finish up the class.
hasMagic = true
inClass = false
re += c
continue

default:
Expand Down Expand Up @@ -721,14 +752,16 @@ class Minimatch {
// Handle nested stuff like *(*.js|!(*.json)), where open parens
// mean that we should *not* include the ) in the bit that is considered
// "after" the negated section.
const openParensBefore = nlBefore.split('(').length - 1
const closeParensBefore = nlBefore.split(')').length
const openParensBefore = nlBefore.split('(').length - closeParensBefore
let cleanAfter = nlAfter
for (let i = 0; i < openParensBefore; i++) {
cleanAfter = cleanAfter.replace(/\)[+*?]?/, '')
}
nlAfter = cleanAfter

const dollar = nlAfter === '' && isSub !== SUBPARSE ? '$' : ''
const dollar = nlAfter === '' && isSub !== SUBPARSE ? '(?:$|\\/)' : ''

re = nlBefore + nlFirst + nlAfter + dollar + nlLast
}

Expand All @@ -740,14 +773,19 @@ class Minimatch {
}

if (addPatternStart) {
re = patternStart + re
re = patternStart() + re
}

// parsing just a piece of a larger pattern.
if (isSub === SUBPARSE) {
return [re, hasMagic]
}

// if it's nocase, and the lcase/uppercase don't match, it's magic
if (options.nocase && !hasMagic) {
hasMagic = pattern.toUpperCase() !== pattern.toLowerCase()
}

// skip the regexp for non-magical patterns
// unescape anything in it, though, so that it'll be
// an exact match against a file etc.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"author": "Isaac Z. Schlueter <[email protected]> (http://blog.izs.me)",
"name": "minimatch",
"description": "a glob matcher in javascript",
"publishConfig": {
"tag": "legacy-v5"
},
"version": "5.1.6",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/minimatch.git"
},
"main": "minimatch.js",
"scripts": {
"test": "tap",
"snap": "tap",
"preversion": "npm test",
"postversion": "npm publish",
"prepublishOnly": "git push origin --follow-tags"
},
"engines": {
"node": ">=10"
},
"dependencies": {
"brace-expansion": "^2.0.1"
},
"devDependencies": {
"tap": "^16.3.2"
},
"license": "ISC",
"files": [
"minimatch.js",
"lib"
]
}
15 changes: 15 additions & 0 deletions node_modules/glob/node_modules/minimatch/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
The ISC License

Copyright (c) 2011-2023 Isaac Z. Schlueter and Contributors

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4 changes: 4 additions & 0 deletions node_modules/glob/node_modules/minimatch/lib/path.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const isWindows = typeof process === 'object' &&
process &&
process.platform === 'win32'
module.exports = isWindows ? { sep: '\\' } : { sep: '/' }
Loading

0 comments on commit 99457f1

Please sign in to comment.