Skip to content
Merged

lk/deps #4786

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
  • Loading branch information
lukekarrys committed Apr 22, 2022
commit 5c6559b73621566249132ea87b132276dd4a05b1
46 changes: 23 additions & 23 deletions node_modules/read-package-json/lib/read-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,22 @@ function parseJson (file, er, d, log, strict, cb) {
delete data[key]
}
}
} catch (er) {
} catch (jsonErr) {
data = parseIndex(d)
if (!data) {
return cb(parseError(er, file))
return cb(parseError(jsonErr, file))
}
}

extrasCached(file, d, data, log, strict, cb)
}

function extrasCached (file, d, data, log, strict, cb) {
extras(file, data, log, strict, function (err, data) {
extras(file, data, log, strict, function (err, extrasData) {
if (!err) {
cache[d] = jsonClone(data)
cache[d] = jsonClone(extrasData)
}
cb(err, data)
cb(err, extrasData)
})
}

Expand Down Expand Up @@ -299,8 +299,8 @@ function readme (file, data, cb) {
return cb(er)
}
// don't accept directories.
files = files.filter(function (file) {
return !file.match(/\/$/)
files = files.filter(function (filtered) {
return !filtered.match(/\/$/)
})
if (!files.length) {
return cb()
Expand Down Expand Up @@ -328,12 +328,12 @@ function preferMarkdownReadme (files) {

function readme_ (file, data, rm, cb) {
var rmfn = path.basename(rm)
fs.readFile(rm, 'utf8', function (er, rm) {
fs.readFile(rm, 'utf8', function (er, rmData) {
// maybe not readable, or something.
if (er) {
return cb()
}
data.readme = rm
data.readme = rmData
data.readmeFilename = rmfn
return cb(er, data)
})
Expand All @@ -346,11 +346,11 @@ function mans (file, data, cb) {
}
const dirname = path.dirname(file)
cwd = path.resolve(path.dirname(file), cwd)
glob('**/*.[0-9]', { cwd }, function (er, mans) {
glob('**/*.[0-9]', { cwd }, function (er, mansGlob) {
if (er) {
return cb(er)
}
data.man = mans.map(man =>
data.man = mansGlob.map(man =>
path.relative(dirname, path.join(cwd, man)).split(path.sep).join('/')
)
return cb(null, data)
Expand All @@ -366,17 +366,17 @@ function bins (file, data, cb) {
}

m = path.resolve(path.dirname(file), m)
glob('**', { cwd: m }, function (er, bins) {
glob('**', { cwd: m }, function (er, binsGlob) {
if (er) {
return cb(er)
}
bins_(file, data, bins, cb)
bins_(file, data, binsGlob, cb)
})
}

function bins_ (file, data, bins, cb) {
function bins_ (file, data, binsGlob, cb) {
var m = (data.directories && data.directories.bin) || '.'
data.bin = bins.reduce(function (acc, mf) {
data.bin = binsGlob.reduce(function (acc, mf) {
if (mf && mf.charAt(0) !== '.') {
var f = path.basename(mf)
acc[f] = path.join(m, mf)
Expand Down Expand Up @@ -412,15 +412,15 @@ function githead (file, data, cb) {
}
var dir = path.dirname(file)
var head = path.resolve(dir, '.git/HEAD')
fs.readFile(head, 'utf8', function (er, head) {
fs.readFile(head, 'utf8', function (er, headData) {
if (er) {
var parent = path.dirname(dir)
if (parent === dir) {
return cb(null, data)
}
return githead(dir, data, cb)
}
githead_(data, dir, head, cb)
githead_(data, dir, headData, cb)
})
}

Expand All @@ -431,11 +431,11 @@ function githead_ (data, dir, head, cb) {
}
var headRef = head.replace(/^ref: /, '').trim()
var headFile = path.resolve(dir, '.git', headRef)
fs.readFile(headFile, 'utf8', function (er, head) {
if (er || !head) {
fs.readFile(headFile, 'utf8', function (er, headData) {
if (er || !headData) {
var packFile = path.resolve(dir, '.git/packed-refs')
return fs.readFile(packFile, 'utf8', function (er, refs) {
if (er || !refs) {
return fs.readFile(packFile, 'utf8', function (readFileErr, refs) {
if (readFileErr || !refs) {
return cb(null, data)
}
refs = refs.split('\n')
Expand All @@ -449,8 +449,8 @@ function githead_ (data, dir, head, cb) {
return cb(null, data)
})
}
head = head.replace(/^ref: /, '').trim()
data.gitHead = head
headData = headData.replace(/^ref: /, '').trim()
data.gitHead = headData
return cb(null, data)
})
}
Expand Down
15 changes: 15 additions & 0 deletions node_modules/read-package-json/node_modules/glob/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
The ISC License

Copyright (c) 2009-2022 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.
238 changes: 238 additions & 0 deletions node_modules/read-package-json/node_modules/glob/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
exports.setopts = setopts
exports.ownProp = ownProp
exports.makeAbs = makeAbs
exports.finish = finish
exports.mark = mark
exports.isIgnored = isIgnored
exports.childrenIgnored = childrenIgnored

function ownProp (obj, field) {
return Object.prototype.hasOwnProperty.call(obj, field)
}

var fs = require("fs")
var path = require("path")
var minimatch = require("minimatch")
var isAbsolute = require("path-is-absolute")
var Minimatch = minimatch.Minimatch

function alphasort (a, b) {
return a.localeCompare(b, 'en')
}

function setupIgnores (self, options) {
self.ignore = options.ignore || []

if (!Array.isArray(self.ignore))
self.ignore = [self.ignore]

if (self.ignore.length) {
self.ignore = self.ignore.map(ignoreMap)
}
}

// ignore patterns are always in dot:true mode.
function ignoreMap (pattern) {
var gmatcher = null
if (pattern.slice(-3) === '/**') {
var gpattern = pattern.replace(/(\/\*\*)+$/, '')
gmatcher = new Minimatch(gpattern, { dot: true })
}

return {
matcher: new Minimatch(pattern, { dot: true }),
gmatcher: gmatcher
}
}

function setopts (self, pattern, options) {
if (!options)
options = {}

// base-matching: just use globstar for that.
if (options.matchBase && -1 === pattern.indexOf("/")) {
if (options.noglobstar) {
throw new Error("base matching requires globstar")
}
pattern = "**/" + pattern
}

self.silent = !!options.silent
self.pattern = pattern
self.strict = options.strict !== false
self.realpath = !!options.realpath
self.realpathCache = options.realpathCache || Object.create(null)
self.follow = !!options.follow
self.dot = !!options.dot
self.mark = !!options.mark
self.nodir = !!options.nodir
if (self.nodir)
self.mark = true
self.sync = !!options.sync
self.nounique = !!options.nounique
self.nonull = !!options.nonull
self.nosort = !!options.nosort
self.nocase = !!options.nocase
self.stat = !!options.stat
self.noprocess = !!options.noprocess
self.absolute = !!options.absolute
self.fs = options.fs || fs

self.maxLength = options.maxLength || Infinity
self.cache = options.cache || Object.create(null)
self.statCache = options.statCache || Object.create(null)
self.symlinks = options.symlinks || Object.create(null)

setupIgnores(self, options)

self.changedCwd = false
var cwd = process.cwd()
if (!ownProp(options, "cwd"))
self.cwd = cwd
else {
self.cwd = path.resolve(options.cwd)
self.changedCwd = self.cwd !== cwd
}

self.root = options.root || path.resolve(self.cwd, "/")
self.root = path.resolve(self.root)
if (process.platform === "win32")
self.root = self.root.replace(/\\/g, "/")

// TODO: is an absolute `cwd` supposed to be resolved against `root`?
// e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test')
self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd)
if (process.platform === "win32")
self.cwdAbs = self.cwdAbs.replace(/\\/g, "/")
self.nomount = !!options.nomount

// disable comments and negation in Minimatch.
// Note that they are not supported in Glob itself anyway.
options.nonegate = true
options.nocomment = true
// always treat \ in patterns as escapes, not path separators
options.allowWindowsEscape = true

self.minimatch = new Minimatch(pattern, options)
self.options = self.minimatch.options
}

function finish (self) {
var nou = self.nounique
var all = nou ? [] : Object.create(null)

for (var i = 0, l = self.matches.length; i < l; i ++) {
var matches = self.matches[i]
if (!matches || Object.keys(matches).length === 0) {
if (self.nonull) {
// do like the shell, and spit out the literal glob
var literal = self.minimatch.globSet[i]
if (nou)
all.push(literal)
else
all[literal] = true
}
} else {
// had matches
var m = Object.keys(matches)
if (nou)
all.push.apply(all, m)
else
m.forEach(function (m) {
all[m] = true
})
}
}

if (!nou)
all = Object.keys(all)

if (!self.nosort)
all = all.sort(alphasort)

// at *some* point we statted all of these
if (self.mark) {
for (var i = 0; i < all.length; i++) {
all[i] = self._mark(all[i])
}
if (self.nodir) {
all = all.filter(function (e) {
var notDir = !(/\/$/.test(e))
var c = self.cache[e] || self.cache[makeAbs(self, e)]
if (notDir && c)
notDir = c !== 'DIR' && !Array.isArray(c)
return notDir
})
}
}

if (self.ignore.length)
all = all.filter(function(m) {
return !isIgnored(self, m)
})

self.found = all
}

function mark (self, p) {
var abs = makeAbs(self, p)
var c = self.cache[abs]
var m = p
if (c) {
var isDir = c === 'DIR' || Array.isArray(c)
var slash = p.slice(-1) === '/'

if (isDir && !slash)
m += '/'
else if (!isDir && slash)
m = m.slice(0, -1)

if (m !== p) {
var mabs = makeAbs(self, m)
self.statCache[mabs] = self.statCache[abs]
self.cache[mabs] = self.cache[abs]
}
}

return m
}

// lotta situps...
function makeAbs (self, f) {
var abs = f
if (f.charAt(0) === '/') {
abs = path.join(self.root, f)
} else if (isAbsolute(f) || f === '') {
abs = f
} else if (self.changedCwd) {
abs = path.resolve(self.cwd, f)
} else {
abs = path.resolve(f)
}

if (process.platform === 'win32')
abs = abs.replace(/\\/g, '/')

return abs
}


// Return true, if pattern ends with globstar '**', for the accompanying parent directory.
// Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents
function isIgnored (self, path) {
if (!self.ignore.length)
return false

return self.ignore.some(function(item) {
return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path))
})
}

function childrenIgnored (self, path) {
if (!self.ignore.length)
return false

return self.ignore.some(function(item) {
return !!(item.gmatcher && item.gmatcher.match(path))
})
}
Loading