$
This commit is contained in:
61
node_modules/istanbul-lib-processinfo/CHANGELOG.md
generated
vendored
Normal file
61
node_modules/istanbul-lib-processinfo/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
### [2.0.2](https://github.com/istanbuljs/istanbul-lib-processinfo/compare/v2.0.1...v2.0.2) (2019-10-08)
|
||||
|
||||
### [2.0.1](https://github.com/istanbuljs/istanbul-lib-processinfo/compare/v2.0.0...v2.0.1) (2019-10-07)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* ProcessInfo#save is now async
|
||||
* ProcessInfo#getCoverageMap is now async
|
||||
* ProcessDB#writeIndex is now async
|
||||
* ProcessDB#readIndex is now async
|
||||
* ProcessDB#readProcessInfos is now async
|
||||
* ProcessDB#renderTree is now async
|
||||
* ProcessDB#buildProcessTree is now async
|
||||
* ProcessDB#getCoverageMap is now async
|
||||
* ProcessDB#spawn now returns a Promise which resolves to
|
||||
the child process object
|
||||
* ProcessDB#spawnSync has been removed
|
||||
* ProcessDB#expunge is now async
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Update dependencies ([e52e64e](https://github.com/istanbuljs/istanbul-lib-processinfo/commit/e52e64e))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Use async where possible ([#14](https://github.com/istanbuljs/istanbul-lib-processinfo/issues/14)) ([67378ab](https://github.com/istanbuljs/istanbul-lib-processinfo/commit/67378ab))
|
||||
|
||||
## [2.0.0](https://github.com/istanbuljs/istanbul-lib-processinfo/compare/v1.0.0...v2.0.0) (2019-06-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Do not crash when nyc is run inside itself. ([#3](https://github.com/istanbuljs/istanbul-lib-processinfo/issues/3)) ([1774277](https://github.com/istanbuljs/istanbul-lib-processinfo/commit/1774277)), closes [istanbuljs/nyc#1068](https://github.com/istanbuljs/istanbul-lib-processinfo/issues/1068)
|
||||
* Eagerly resolve processInfoDirectory ([#8](https://github.com/istanbuljs/istanbul-lib-processinfo/issues/8)) ([c2a5fa8](https://github.com/istanbuljs/istanbul-lib-processinfo/commit/c2a5fa8))
|
||||
* Just use externalId from argument. ([#7](https://github.com/istanbuljs/istanbul-lib-processinfo/issues/7)) ([d25b1ed](https://github.com/istanbuljs/istanbul-lib-processinfo/commit/d25b1ed))
|
||||
* Name field/property `directory` ([#11](https://github.com/istanbuljs/istanbul-lib-processinfo/issues/11)) ([b70207e](https://github.com/istanbuljs/istanbul-lib-processinfo/commit/b70207e))
|
||||
* Remove `root` from processinfo ([#9](https://github.com/istanbuljs/istanbul-lib-processinfo/issues/9)) ([2c2086a](https://github.com/istanbuljs/istanbul-lib-processinfo/commit/2c2086a))
|
||||
* Switch from mkdirp to make-dir, add to dependencies ([#5](https://github.com/istanbuljs/istanbul-lib-processinfo/issues/5)) ([63b5e19](https://github.com/istanbuljs/istanbul-lib-processinfo/commit/63b5e19))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Require Node.js 8, update dependencies ([#10](https://github.com/istanbuljs/istanbul-lib-processinfo/issues/10)) ([36f03c0](https://github.com/istanbuljs/istanbul-lib-processinfo/commit/36f03c0))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* ProcessInfo field and property `processInfoDirectory` is
|
||||
renamed to `directory`.
|
||||
* ProcessDB readonly property `dir` is renamed to
|
||||
`directory`.
|
||||
* ProcessInfo directory must be set if `.save()` will be
|
||||
used. It is no longer calculated from NYC_CONFIG environment.
|
||||
* Require Node.js 8, update dependencies (#10)
|
||||
* The `root` field has been removed from processinfo files.
|
15
node_modules/istanbul-lib-processinfo/LICENSE
generated
vendored
Normal file
15
node_modules/istanbul-lib-processinfo/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) 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.
|
188
node_modules/istanbul-lib-processinfo/README.md
generated
vendored
Normal file
188
node_modules/istanbul-lib-processinfo/README.md
generated
vendored
Normal file
@@ -0,0 +1,188 @@
|
||||
# istanbul-lib-processinfo
|
||||
|
||||
A utility for managing the `processinfo` folder that NYC uses.
|
||||
|
||||
This is intended to be used along with [NYC](https://npm.im/nyc), but can also
|
||||
be used by other tools that wish to consume NYC's processinfo data.
|
||||
|
||||
## API
|
||||
|
||||
### class ProcessInfo
|
||||
|
||||
A representation of information about a single process.
|
||||
|
||||
#### constructor(fields)
|
||||
|
||||
Pass in fields that will be printed to the processinfo file. Several defaults
|
||||
will be provided if not specified.
|
||||
|
||||
#### async processInfo.save()
|
||||
|
||||
Write this process info to disk. This works by passing the ProcessInfo object
|
||||
to JSON.stringify, and writing to `${this.directory}/${this.uuid}.json`.
|
||||
|
||||
#### processInfo.saveSync()
|
||||
|
||||
The synchronous version of `.save()`.
|
||||
|
||||
#### async processInfo.getCoverageMap(nyc)
|
||||
|
||||
Get a merged coverage map of the current process, as well as any child
|
||||
processes. This should only be called during tree rendering, as it depends on
|
||||
child nodes being present in the `nodes` array.
|
||||
|
||||
The `nyc` instance is required to load the report information and apply
|
||||
sourcemaps properly.
|
||||
|
||||
### processInfo.label
|
||||
|
||||
A read-only string for when archy prints the process tree.
|
||||
|
||||
### processInfo.nodes
|
||||
|
||||
A list of the child nodes used during tree rendering.
|
||||
|
||||
### processInfo.directory
|
||||
|
||||
If a process will be saved, it must have a `directory` included
|
||||
in the list of fields. This property is not saved to the processinfo file.
|
||||
|
||||
## class ProcessDB
|
||||
|
||||
A utility for interacting with the collection of ProcessInfo files in the
|
||||
processinfo folder.
|
||||
|
||||
### constructor(directory)
|
||||
|
||||
Supply the directory where processinfo files are found. This should be the
|
||||
full path, something like `${cwd}/.nyc_output/processinfo`.
|
||||
|
||||
### processDB.directory
|
||||
|
||||
A read-only property showing the directory where this object is working.
|
||||
|
||||
### processDB.nodes
|
||||
|
||||
A list of child ProcessInfo nodes used in tree printing.
|
||||
|
||||
### processDB.label
|
||||
|
||||
The string `'nyc'`, used as the default root node in the archy tree rendering.
|
||||
|
||||
### async processDB.writeIndex()
|
||||
|
||||
Create the `index.json` file in the processinfo folder, which is required for
|
||||
tree generation and expunging.
|
||||
|
||||
WARNING: Index writing is non-atomic, and should not be performed by multiple
|
||||
processes.
|
||||
|
||||
### async processDB.readIndex()
|
||||
|
||||
Read and return the contents of the `index.json` file. If the `index.json` is
|
||||
not present or not valid, then it will attempt to generate one.
|
||||
|
||||
### async processDB.readProcessInfos()
|
||||
|
||||
Read all the data files in the processinfo folder, and return an object mapping
|
||||
the file basename to the resulting object. Used in tree generation.
|
||||
|
||||
### async processDB.renderTree(nyc)
|
||||
|
||||
Render the tree as a string using archy, suitable for printing to the terminal.
|
||||
|
||||
### async processDB.buildProcessTree()
|
||||
|
||||
Build the hierarchical tree of nodes for tree rendering. Populates the `nodes`
|
||||
array of this object and all `ProcessInfo` objects in the tree.
|
||||
|
||||
### async processDB.getCoverageMap(nyc)
|
||||
|
||||
Used in tree rendering, to show the total coverage of all the processinfo files
|
||||
in the data folder.
|
||||
|
||||
### async processDB.spawn(name, file, args, options)
|
||||
|
||||
Spawn a child process with a unique name provided by the caller. This name is
|
||||
stored as the `externalId` property in the child process's `ProcessInfo` data,
|
||||
and is tracked in the `externalIds` section of the index.
|
||||
|
||||
Note that if the current process is not already wrapped by nyc, then you must
|
||||
prefix the spawned program with nyc, in order for this to take effect. For
|
||||
example, instead of `processDB.spawn('foo', 'node', ['foo.js'])`, you would run
|
||||
`processDB.spawn('foo', 'nyc', ['node', 'foo.js'])`.
|
||||
|
||||
If a process with that name already exists in the index, then it will be
|
||||
expunged.
|
||||
|
||||
Unlike `child_process.spawn` this function returns a Promise which resolves to
|
||||
the `ChildProcess` object.
|
||||
|
||||
WARNING: Calling `expunge` (which this method does) will result in the index
|
||||
being out of date. It is the caller's responsibility to call
|
||||
`processDB.writeIndex()` when all named processes are completed.
|
||||
|
||||
### async processDB.expunge(name)
|
||||
|
||||
If a process exists in the process info data folder with the specified name
|
||||
(ie, it had previously been run with `processDB.spawn(name, ...)`) then the
|
||||
coverage and processinfo files for it and all of its children are removed.
|
||||
|
||||
This allows for a test harness to re-run or resume test suites, without
|
||||
spurious coverage results.
|
||||
|
||||
WARNING: Calling `expunge` will result in the index being out of date. It is
|
||||
the caller's responsibility to call `processDB.writeIndex()` when all named
|
||||
processes are completed.
|
||||
|
||||
## DATA STRUCTURES and FILES
|
||||
|
||||
ProcessInfo files MUST match the following structure:
|
||||
|
||||
```
|
||||
{
|
||||
"uuid": "UUID of the process itself",
|
||||
"parent": "UUID of the parent process, or null",
|
||||
"pid": Number,
|
||||
"ppid": Number (pid of parent process),
|
||||
"argv": Array<String>,
|
||||
"execArgv": Array<String>,
|
||||
"cwd": path,
|
||||
"time": Number (timestamp in ms),
|
||||
"coverageFilename": "Path to NYC coverage info for this process",
|
||||
"externalId": "The externally specified name for this process, or null",
|
||||
}
|
||||
```
|
||||
|
||||
The index file is saved to `${this.directory}/index.json`. It has
|
||||
the following structure:
|
||||
|
||||
```
|
||||
{
|
||||
"processes": {
|
||||
"<uuid>": {
|
||||
"parent": "parent uuid, or null",
|
||||
"children": ["children", "uuids", "or empty array"],
|
||||
"externalId": "externally specified name, if provided"
|
||||
},
|
||||
...
|
||||
},
|
||||
"files": {
|
||||
"/path/to/covered/file.js": [
|
||||
"<uuids of processes that covered this file>",
|
||||
...
|
||||
],
|
||||
...
|
||||
},
|
||||
"externalIds": {
|
||||
"externally specified name": {
|
||||
"root": "<uuid of process run under this name>",
|
||||
"children": [
|
||||
"<uuids of all descendant processes from this point in the tree>",
|
||||
...
|
||||
]
|
||||
},
|
||||
...
|
||||
}
|
||||
}
|
||||
```
|
347
node_modules/istanbul-lib-processinfo/index.js
generated
vendored
Normal file
347
node_modules/istanbul-lib-processinfo/index.js
generated
vendored
Normal file
@@ -0,0 +1,347 @@
|
||||
'use strict'
|
||||
const uuid = require('uuid/v4')
|
||||
const archy = require('archy')
|
||||
const libCoverage = require('istanbul-lib-coverage')
|
||||
const {dirname, resolve} = require('path')
|
||||
const {promisify} = require('util')
|
||||
/* Shallow clone so we can promisify in-place */
|
||||
const fs = { ...require('fs') }
|
||||
const {spawn} = require('cross-spawn')
|
||||
const rimraf = promisify(require('rimraf'))
|
||||
const pMap = require('p-map')
|
||||
|
||||
const _nodes = Symbol('nodes')
|
||||
const _label = Symbol('label')
|
||||
const _coverageMap = Symbol('coverageMap')
|
||||
const _processInfoDirectory = Symbol('processInfo.directory')
|
||||
// shared symbol for testing
|
||||
const _spawnArgs = Symbol.for('spawnArgs')
|
||||
|
||||
;['writeFile', 'readFile', 'readdir'].forEach(fn => {
|
||||
fs[fn] = promisify(fs[fn])
|
||||
})
|
||||
|
||||
// the enumerable fields
|
||||
const defaults = () => ({
|
||||
parent: null,
|
||||
pid: process.pid,
|
||||
argv: process.argv,
|
||||
execArgv: process.execArgv,
|
||||
cwd: process.cwd(),
|
||||
time: Date.now(),
|
||||
ppid: process.ppid,
|
||||
coverageFilename: null,
|
||||
externalId: '',
|
||||
[_nodes]: [],
|
||||
[_label]: null,
|
||||
[_coverageMap]: null
|
||||
})
|
||||
|
||||
/* istanbul ignore next */
|
||||
const fromEntries = Object.fromEntries || (
|
||||
entries => entries.reduce((obj, [name, value]) => {
|
||||
obj[name] = value
|
||||
return obj
|
||||
}, {})
|
||||
)
|
||||
|
||||
class ProcessInfo {
|
||||
constructor (fields = {}) {
|
||||
Object.assign(this, defaults(), fields)
|
||||
|
||||
if (!this.uuid) {
|
||||
this.uuid = uuid()
|
||||
}
|
||||
}
|
||||
|
||||
get nodes () {
|
||||
return this[_nodes]
|
||||
}
|
||||
|
||||
set nodes (n) {
|
||||
this[_nodes] = n
|
||||
}
|
||||
|
||||
set directory (d) {
|
||||
this[_processInfoDirectory] = resolve(d)
|
||||
}
|
||||
|
||||
get directory () {
|
||||
return this[_processInfoDirectory]
|
||||
}
|
||||
|
||||
saveSync () {
|
||||
const f = resolve(this.directory, this.uuid + '.json')
|
||||
fs.writeFileSync(f, JSON.stringify(this), 'utf-8')
|
||||
}
|
||||
|
||||
async save () {
|
||||
const f = resolve(this.directory, this.uuid + '.json')
|
||||
await fs.writeFile(f, JSON.stringify(this), 'utf-8')
|
||||
}
|
||||
|
||||
async getCoverageMap (nyc) {
|
||||
if (this[_coverageMap]) {
|
||||
return this[_coverageMap]
|
||||
}
|
||||
|
||||
const childMaps = await Promise.all(this.nodes.map(child => child.getCoverageMap(nyc)))
|
||||
|
||||
this[_coverageMap] = await mapMerger(nyc, this.coverageFilename, childMaps)
|
||||
|
||||
return this[_coverageMap]
|
||||
}
|
||||
|
||||
get label () {
|
||||
if (this[_label]) {
|
||||
return this[_label]
|
||||
}
|
||||
|
||||
const covInfo = this[_coverageMap]
|
||||
? '\n ' + this[_coverageMap].getCoverageSummary().lines.pct + ' % Lines'
|
||||
: ''
|
||||
|
||||
return this[_label] = this.argv.join(' ') + covInfo
|
||||
}
|
||||
}
|
||||
|
||||
const mapMerger = async (nyc, filename, maps) => {
|
||||
const map = libCoverage.createCoverageMap({})
|
||||
if (filename) {
|
||||
map.merge(await nyc.coverageFileLoad(filename))
|
||||
}
|
||||
maps.forEach(otherMap => map.merge(otherMap))
|
||||
return map
|
||||
}
|
||||
|
||||
// Operations on the processinfo database as a whole,
|
||||
// and the root of the tree rendering operation.
|
||||
class ProcessDB {
|
||||
constructor (directory) {
|
||||
if (!directory) {
|
||||
const nycConfig = process.env.NYC_CONFIG;
|
||||
if (nycConfig) {
|
||||
directory = resolve(JSON.parse(nycConfig).tempDir, 'processinfo')
|
||||
}
|
||||
|
||||
if (!directory) {
|
||||
throw new TypeError('must provide directory argument when outside of NYC')
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperty(this, 'directory', { get: () => directory, enumerable: true })
|
||||
this.nodes = []
|
||||
this[_label] = null
|
||||
this[_coverageMap] = null
|
||||
}
|
||||
|
||||
get label () {
|
||||
if (this[_label]) {
|
||||
return this[_label]
|
||||
}
|
||||
|
||||
const covInfo = this[_coverageMap]
|
||||
? '\n ' + this[_coverageMap].getCoverageSummary().lines.pct + ' % Lines'
|
||||
: ''
|
||||
|
||||
return this[_label] = 'nyc' + covInfo
|
||||
}
|
||||
|
||||
async getCoverageMap (nyc) {
|
||||
if (this[_coverageMap]) {
|
||||
return this[_coverageMap]
|
||||
}
|
||||
|
||||
const childMaps = await Promise.all(this.nodes.map(child => child.getCoverageMap(nyc)))
|
||||
this[_coverageMap] = await mapMerger(nyc, undefined, childMaps)
|
||||
return this[_coverageMap]
|
||||
}
|
||||
|
||||
async renderTree (nyc) {
|
||||
await this.buildProcessTree()
|
||||
await this.getCoverageMap(nyc)
|
||||
|
||||
return archy(this)
|
||||
}
|
||||
|
||||
async buildProcessTree () {
|
||||
const infos = await this.readProcessInfos(this.directory)
|
||||
const index = await this.readIndex()
|
||||
for (const id in index.processes) {
|
||||
const node = infos[id]
|
||||
if (!node) {
|
||||
throw new Error(`Invalid entry in processinfo index: ${id}`)
|
||||
}
|
||||
const idx = index.processes[id]
|
||||
node.nodes = idx.children.map(id => infos[id])
|
||||
.sort((a, b) => a.time - b.time)
|
||||
if (!node.parent) {
|
||||
this.nodes.push(node)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async _readJSON (file) {
|
||||
if (Array.isArray(file)) {
|
||||
const result = await pMap(
|
||||
file,
|
||||
f => this._readJSON(f),
|
||||
{ concurrency: 8 }
|
||||
)
|
||||
return result.filter(Boolean)
|
||||
}
|
||||
|
||||
try {
|
||||
return JSON.parse(await fs.readFile(resolve(this.directory, file), 'utf-8'))
|
||||
} catch (error) {
|
||||
}
|
||||
}
|
||||
|
||||
async readProcessInfos () {
|
||||
const files = await fs.readdir(this.directory)
|
||||
const fileData = await this._readJSON(files.filter(f => f !== 'index.json'))
|
||||
|
||||
return fromEntries(fileData.map(info => [
|
||||
info.uuid,
|
||||
new ProcessInfo(info)
|
||||
]))
|
||||
}
|
||||
|
||||
_createIndex (infos) {
|
||||
const infoMap = fromEntries(infos.map(info => [
|
||||
info.uuid,
|
||||
Object.assign(info, {children: []})
|
||||
]))
|
||||
|
||||
// create all the parent-child links
|
||||
infos.forEach(info => {
|
||||
if (info.parent) {
|
||||
const parentInfo = infoMap[info.parent]
|
||||
if (parentInfo && !parentInfo.children.includes(info.uuid)) {
|
||||
parentInfo.children.push(info.uuid)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// figure out which files were touched by each process.
|
||||
const files = infos.reduce((files, info) => {
|
||||
info.files.forEach(f => {
|
||||
files[f] = files[f] || []
|
||||
if (!files[f].includes(info.uuid)) {
|
||||
files[f].push(info.uuid)
|
||||
}
|
||||
})
|
||||
return files
|
||||
}, {})
|
||||
|
||||
const processes = fromEntries(infos.map(info => [
|
||||
info.uuid,
|
||||
{
|
||||
parent: info.parent,
|
||||
...(info.externalId ? { externalId: info.externalId } : {}),
|
||||
children: Array.from(info.children)
|
||||
}
|
||||
]))
|
||||
|
||||
const eidList = new Set()
|
||||
const externalIds = fromEntries(infos.filter(info => info.externalId).map(info => {
|
||||
if (eidList.has(info.externalId)) {
|
||||
throw new Error(
|
||||
`External ID ${info.externalId} used by multiple processes`)
|
||||
}
|
||||
|
||||
eidList.add(info.externalId)
|
||||
|
||||
const children = Array.from(info.children)
|
||||
// flatten the descendant sets of all the externalId procs
|
||||
// push the next generation onto the list so we accumulate them all
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
children.push(...processes[children[i]].children.filter(uuid => !children.includes(uuid)))
|
||||
}
|
||||
|
||||
return [
|
||||
info.externalId,
|
||||
{
|
||||
root: info.uuid,
|
||||
children
|
||||
}
|
||||
]
|
||||
}))
|
||||
|
||||
return { processes, files, externalIds }
|
||||
}
|
||||
|
||||
async writeIndex () {
|
||||
const {directory} = this
|
||||
const files = await fs.readdir(directory)
|
||||
const infos = await this._readJSON(files.filter(f => f !== 'index.json'))
|
||||
const index = this._createIndex(infos)
|
||||
const indexFile = resolve(directory, 'index.json')
|
||||
await fs.writeFile(indexFile, JSON.stringify(index))
|
||||
|
||||
return index
|
||||
}
|
||||
|
||||
async readIndex () {
|
||||
return await this._readJSON('index.json') || await this.writeIndex()
|
||||
}
|
||||
|
||||
// delete all coverage and processinfo for a given process
|
||||
// Warning! Doing this makes the index out of date, so make sure
|
||||
// to update it when you're done!
|
||||
// Not multi-process safe, because it cannot be done atomically.
|
||||
async expunge (id) {
|
||||
const index = await this.readIndex()
|
||||
const entry = index.externalIds[id]
|
||||
if (!entry) {
|
||||
return
|
||||
}
|
||||
|
||||
await pMap(
|
||||
[].concat(
|
||||
`${dirname(this.directory)}/${entry.root}.json`,
|
||||
`${this.directory}/${entry.root}.json`,
|
||||
...entry.children.map(c => [
|
||||
`${dirname(this.directory)}/${c}.json`,
|
||||
`${this.directory}/${c}.json`
|
||||
])
|
||||
),
|
||||
f => rimraf(f),
|
||||
{ concurrency: 8 }
|
||||
)
|
||||
}
|
||||
|
||||
[_spawnArgs] (name, file, args, options) {
|
||||
if (!Array.isArray(args)) {
|
||||
options = args
|
||||
args = []
|
||||
}
|
||||
if (!options) {
|
||||
options = {}
|
||||
}
|
||||
|
||||
if (!process.env.NYC_CONFIG) {
|
||||
const nyc = options.nyc || 'nyc'
|
||||
const nycArgs = options.nycArgs || []
|
||||
args = [...nycArgs, file, ...args]
|
||||
file = nyc
|
||||
}
|
||||
|
||||
options.env = {
|
||||
...(options.env || process.env),
|
||||
NYC_PROCESSINFO_EXTERNAL_ID: name
|
||||
}
|
||||
|
||||
return [name, file, args, options]
|
||||
}
|
||||
|
||||
// spawn an externally named process
|
||||
async spawn (...spawnArgs) {
|
||||
const [name, file, args, options] = this[_spawnArgs](...spawnArgs)
|
||||
await this.expunge(name)
|
||||
return spawn(file, args, options)
|
||||
}
|
||||
}
|
||||
|
||||
exports.ProcessDB = ProcessDB
|
||||
exports.ProcessInfo = ProcessInfo
|
66
node_modules/istanbul-lib-processinfo/node_modules/make-dir/index.d.ts
generated
vendored
Normal file
66
node_modules/istanbul-lib-processinfo/node_modules/make-dir/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
/// <reference types="node"/>
|
||||
import * as fs from 'fs';
|
||||
|
||||
declare namespace makeDir {
|
||||
interface Options {
|
||||
/**
|
||||
Directory [permissions](https://x-team.com/blog/file-system-permissions-umask-node-js/).
|
||||
|
||||
@default 0o777
|
||||
*/
|
||||
readonly mode?: number;
|
||||
|
||||
/**
|
||||
Use a custom `fs` implementation. For example [`graceful-fs`](https://github.com/isaacs/node-graceful-fs).
|
||||
|
||||
Using a custom `fs` implementation will block the use of the native `recursive` option if `fs.mkdir` or `fs.mkdirSync` is not the native function.
|
||||
|
||||
@default require('fs')
|
||||
*/
|
||||
readonly fs?: typeof fs;
|
||||
}
|
||||
}
|
||||
|
||||
declare const makeDir: {
|
||||
/**
|
||||
Make a directory and its parents if needed - Think `mkdir -p`.
|
||||
|
||||
@param path - Directory to create.
|
||||
@returns The path to the created directory.
|
||||
|
||||
@example
|
||||
```
|
||||
import makeDir = require('make-dir');
|
||||
|
||||
(async () => {
|
||||
const path = await makeDir('unicorn/rainbow/cake');
|
||||
|
||||
console.log(path);
|
||||
//=> '/Users/sindresorhus/fun/unicorn/rainbow/cake'
|
||||
|
||||
// Multiple directories:
|
||||
const paths = await Promise.all([
|
||||
makeDir('unicorn/rainbow'),
|
||||
makeDir('foo/bar')
|
||||
]);
|
||||
|
||||
console.log(paths);
|
||||
// [
|
||||
// '/Users/sindresorhus/fun/unicorn/rainbow',
|
||||
// '/Users/sindresorhus/fun/foo/bar'
|
||||
// ]
|
||||
})();
|
||||
```
|
||||
*/
|
||||
(path: string, options?: makeDir.Options): Promise<string>;
|
||||
|
||||
/**
|
||||
Synchronously make a directory and its parents if needed - Think `mkdir -p`.
|
||||
|
||||
@param path - Directory to create.
|
||||
@returns The path to the created directory.
|
||||
*/
|
||||
sync(path: string, options?: makeDir.Options): string;
|
||||
};
|
||||
|
||||
export = makeDir;
|
156
node_modules/istanbul-lib-processinfo/node_modules/make-dir/index.js
generated
vendored
Normal file
156
node_modules/istanbul-lib-processinfo/node_modules/make-dir/index.js
generated
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const {promisify} = require('util');
|
||||
const semver = require('semver');
|
||||
|
||||
const useNativeRecursiveOption = semver.satisfies(process.version, '>=10.12.0');
|
||||
|
||||
// https://github.com/nodejs/node/issues/8987
|
||||
// https://github.com/libuv/libuv/pull/1088
|
||||
const checkPath = pth => {
|
||||
if (process.platform === 'win32') {
|
||||
const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ''));
|
||||
|
||||
if (pathHasInvalidWinCharacters) {
|
||||
const error = new Error(`Path contains invalid characters: ${pth}`);
|
||||
error.code = 'EINVAL';
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const processOptions = options => {
|
||||
// https://github.com/sindresorhus/make-dir/issues/18
|
||||
const defaults = {
|
||||
mode: 0o777,
|
||||
fs
|
||||
};
|
||||
|
||||
return {
|
||||
...defaults,
|
||||
...options
|
||||
};
|
||||
};
|
||||
|
||||
const permissionError = pth => {
|
||||
// This replicates the exception of `fs.mkdir` with native the
|
||||
// `recusive` option when run on an invalid drive under Windows.
|
||||
const error = new Error(`operation not permitted, mkdir '${pth}'`);
|
||||
error.code = 'EPERM';
|
||||
error.errno = -4048;
|
||||
error.path = pth;
|
||||
error.syscall = 'mkdir';
|
||||
return error;
|
||||
};
|
||||
|
||||
const makeDir = async (input, options) => {
|
||||
checkPath(input);
|
||||
options = processOptions(options);
|
||||
|
||||
const mkdir = promisify(options.fs.mkdir);
|
||||
const stat = promisify(options.fs.stat);
|
||||
|
||||
if (useNativeRecursiveOption && options.fs.mkdir === fs.mkdir) {
|
||||
const pth = path.resolve(input);
|
||||
|
||||
await mkdir(pth, {
|
||||
mode: options.mode,
|
||||
recursive: true
|
||||
});
|
||||
|
||||
return pth;
|
||||
}
|
||||
|
||||
const make = async pth => {
|
||||
try {
|
||||
await mkdir(pth, options.mode);
|
||||
|
||||
return pth;
|
||||
} catch (error) {
|
||||
if (error.code === 'EPERM') {
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (error.code === 'ENOENT') {
|
||||
if (path.dirname(pth) === pth) {
|
||||
throw permissionError(pth);
|
||||
}
|
||||
|
||||
if (error.message.includes('null bytes')) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
await make(path.dirname(pth));
|
||||
|
||||
return make(pth);
|
||||
}
|
||||
|
||||
try {
|
||||
const stats = await stat(pth);
|
||||
if (!stats.isDirectory()) {
|
||||
throw new Error('The path is not a directory');
|
||||
}
|
||||
} catch (_) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return pth;
|
||||
}
|
||||
};
|
||||
|
||||
return make(path.resolve(input));
|
||||
};
|
||||
|
||||
module.exports = makeDir;
|
||||
|
||||
module.exports.sync = (input, options) => {
|
||||
checkPath(input);
|
||||
options = processOptions(options);
|
||||
|
||||
if (useNativeRecursiveOption && options.fs.mkdirSync === fs.mkdirSync) {
|
||||
const pth = path.resolve(input);
|
||||
|
||||
fs.mkdirSync(pth, {
|
||||
mode: options.mode,
|
||||
recursive: true
|
||||
});
|
||||
|
||||
return pth;
|
||||
}
|
||||
|
||||
const make = pth => {
|
||||
try {
|
||||
options.fs.mkdirSync(pth, options.mode);
|
||||
} catch (error) {
|
||||
if (error.code === 'EPERM') {
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (error.code === 'ENOENT') {
|
||||
if (path.dirname(pth) === pth) {
|
||||
throw permissionError(pth);
|
||||
}
|
||||
|
||||
if (error.message.includes('null bytes')) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
make(path.dirname(pth));
|
||||
return make(pth);
|
||||
}
|
||||
|
||||
try {
|
||||
if (!options.fs.statSync(pth).isDirectory()) {
|
||||
throw new Error('The path is not a directory');
|
||||
}
|
||||
} catch (_) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return pth;
|
||||
};
|
||||
|
||||
return make(path.resolve(input));
|
||||
};
|
9
node_modules/istanbul-lib-processinfo/node_modules/make-dir/license
generated
vendored
Normal file
9
node_modules/istanbul-lib-processinfo/node_modules/make-dir/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
59
node_modules/istanbul-lib-processinfo/node_modules/make-dir/package.json
generated
vendored
Normal file
59
node_modules/istanbul-lib-processinfo/node_modules/make-dir/package.json
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"name": "make-dir",
|
||||
"version": "3.1.0",
|
||||
"description": "Make a directory and its parents if needed - Think `mkdir -p`",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/make-dir",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && nyc ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"mkdir",
|
||||
"mkdirp",
|
||||
"make",
|
||||
"directories",
|
||||
"dir",
|
||||
"dirs",
|
||||
"folders",
|
||||
"directory",
|
||||
"folder",
|
||||
"path",
|
||||
"parent",
|
||||
"parents",
|
||||
"intermediate",
|
||||
"recursively",
|
||||
"recursive",
|
||||
"create",
|
||||
"fs",
|
||||
"filesystem",
|
||||
"file-system"
|
||||
],
|
||||
"dependencies": {
|
||||
"semver": "^6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/graceful-fs": "^4.1.3",
|
||||
"@types/node": "^13.7.1",
|
||||
"ava": "^1.4.0",
|
||||
"codecov": "^3.2.0",
|
||||
"graceful-fs": "^4.1.15",
|
||||
"nyc": "^15.0.0",
|
||||
"path-type": "^4.0.0",
|
||||
"tempy": "^0.2.1",
|
||||
"tsd": "^0.11.0",
|
||||
"xo": "^0.25.4"
|
||||
}
|
||||
}
|
125
node_modules/istanbul-lib-processinfo/node_modules/make-dir/readme.md
generated
vendored
Normal file
125
node_modules/istanbul-lib-processinfo/node_modules/make-dir/readme.md
generated
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
# make-dir [](https://travis-ci.org/sindresorhus/make-dir) [](https://codecov.io/gh/sindresorhus/make-dir)
|
||||
|
||||
> Make a directory and its parents if needed - Think `mkdir -p`
|
||||
|
||||
## Advantages over [`mkdirp`](https://github.com/substack/node-mkdirp)
|
||||
|
||||
- Promise API *(Async/await ready!)*
|
||||
- Fixes many `mkdirp` issues: [#96](https://github.com/substack/node-mkdirp/pull/96) [#70](https://github.com/substack/node-mkdirp/issues/70) [#66](https://github.com/substack/node-mkdirp/issues/66)
|
||||
- 100% test coverage
|
||||
- CI-tested on macOS, Linux, and Windows
|
||||
- Actively maintained
|
||||
- Doesn't bundle a CLI
|
||||
- Uses the native `fs.mkdir/mkdirSync` [`recursive` option](https://nodejs.org/dist/latest/docs/api/fs.html#fs_fs_mkdir_path_options_callback) in Node.js >=10.12.0 unless [overridden](#fs)
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install make-dir
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
$ pwd
|
||||
/Users/sindresorhus/fun
|
||||
$ tree
|
||||
.
|
||||
```
|
||||
|
||||
```js
|
||||
const makeDir = require('make-dir');
|
||||
|
||||
(async () => {
|
||||
const path = await makeDir('unicorn/rainbow/cake');
|
||||
|
||||
console.log(path);
|
||||
//=> '/Users/sindresorhus/fun/unicorn/rainbow/cake'
|
||||
})();
|
||||
```
|
||||
|
||||
```
|
||||
$ tree
|
||||
.
|
||||
└── unicorn
|
||||
└── rainbow
|
||||
└── cake
|
||||
```
|
||||
|
||||
Multiple directories:
|
||||
|
||||
```js
|
||||
const makeDir = require('make-dir');
|
||||
|
||||
(async () => {
|
||||
const paths = await Promise.all([
|
||||
makeDir('unicorn/rainbow'),
|
||||
makeDir('foo/bar')
|
||||
]);
|
||||
|
||||
console.log(paths);
|
||||
/*
|
||||
[
|
||||
'/Users/sindresorhus/fun/unicorn/rainbow',
|
||||
'/Users/sindresorhus/fun/foo/bar'
|
||||
]
|
||||
*/
|
||||
})();
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### makeDir(path, options?)
|
||||
|
||||
Returns a `Promise` for the path to the created directory.
|
||||
|
||||
### makeDir.sync(path, options?)
|
||||
|
||||
Returns the path to the created directory.
|
||||
|
||||
#### path
|
||||
|
||||
Type: `string`
|
||||
|
||||
Directory to create.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### mode
|
||||
|
||||
Type: `integer`\
|
||||
Default: `0o777`
|
||||
|
||||
Directory [permissions](https://x-team.com/blog/file-system-permissions-umask-node-js/).
|
||||
|
||||
##### fs
|
||||
|
||||
Type: `object`\
|
||||
Default: `require('fs')`
|
||||
|
||||
Use a custom `fs` implementation. For example [`graceful-fs`](https://github.com/isaacs/node-graceful-fs).
|
||||
|
||||
Using a custom `fs` implementation will block the use of the native `recursive` option if `fs.mkdir` or `fs.mkdirSync` is not the native function.
|
||||
|
||||
## Related
|
||||
|
||||
- [make-dir-cli](https://github.com/sindresorhus/make-dir-cli) - CLI for this module
|
||||
- [del](https://github.com/sindresorhus/del) - Delete files and directories
|
||||
- [globby](https://github.com/sindresorhus/globby) - User-friendly glob matching
|
||||
- [cpy](https://github.com/sindresorhus/cpy) - Copy files
|
||||
- [cpy-cli](https://github.com/sindresorhus/cpy-cli) - Copy files on the command-line
|
||||
- [move-file](https://github.com/sindresorhus/move-file) - Move a file
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-make-dir?utm_source=npm-make-dir&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
43
node_modules/istanbul-lib-processinfo/package.json
generated
vendored
Normal file
43
node_modules/istanbul-lib-processinfo/package.json
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "istanbul-lib-processinfo",
|
||||
"version": "2.0.2",
|
||||
"description": "A utility for managing the `processinfo` folder that NYC uses.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "tap",
|
||||
"snap": "tap",
|
||||
"release": "standard-version"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/istanbuljs/istanbul-lib-processinfo.git"
|
||||
},
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"archy": "^1.0.0",
|
||||
"cross-spawn": "^7.0.0",
|
||||
"istanbul-lib-coverage": "^3.0.0-alpha.1",
|
||||
"make-dir": "^3.0.0",
|
||||
"p-map": "^3.0.0",
|
||||
"rimraf": "^3.0.0",
|
||||
"uuid": "^3.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"standard-version": "^7.0.0",
|
||||
"tap": "^14.6.5",
|
||||
"nyc": "^15.0.0-alpha.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"tap": {
|
||||
"check-coverage": true,
|
||||
"jobs": 1
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"nyc": {
|
||||
"include": "index.js"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user