-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
894 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!-- This file is automatically added by @npmcli/template-oss. Do not edit. --> | ||
|
||
ISC License | ||
|
||
Copyright npm, Inc. | ||
|
||
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 NPM DISCLAIMS ALL | ||
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO | ||
EVENT SHALL NPM 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. |
20 changes: 20 additions & 0 deletions
20
node_modules/cacache/node_modules/@npmcli/fs/lib/common/get-options.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// given an input that may or may not be an object, return an object that has | ||
// a copy of every defined property listed in 'copy'. if the input is not an | ||
// object, assign it to the property named by 'wrap' | ||
const getOptions = (input, { copy, wrap }) => { | ||
const result = {} | ||
|
||
if (input && typeof input === 'object') { | ||
for (const prop of copy) { | ||
if (input[prop] !== undefined) { | ||
result[prop] = input[prop] | ||
} | ||
} | ||
} else { | ||
result[wrap] = input | ||
} | ||
|
||
return result | ||
} | ||
|
||
module.exports = getOptions |
9 changes: 9 additions & 0 deletions
9
node_modules/cacache/node_modules/@npmcli/fs/lib/common/node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const semver = require('semver') | ||
|
||
const satisfies = (range) => { | ||
return semver.satisfies(process.version, range, { includePrerelease: true }) | ||
} | ||
|
||
module.exports = { | ||
satisfies, | ||
} |
15 changes: 15 additions & 0 deletions
15
node_modules/cacache/node_modules/@npmcli/fs/lib/cp/LICENSE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
(The MIT License) | ||
|
||
Copyright (c) 2011-2017 JP Richardson | ||
|
||
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. |
129 changes: 129 additions & 0 deletions
129
node_modules/cacache/node_modules/@npmcli/fs/lib/cp/errors.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
'use strict' | ||
const { inspect } = require('util') | ||
|
||
// adapted from node's internal/errors | ||
// https://github.com/nodejs/node/blob/c8a04049/lib/internal/errors.js | ||
|
||
// close copy of node's internal SystemError class. | ||
class SystemError { | ||
constructor (code, prefix, context) { | ||
// XXX context.code is undefined in all constructors used in cp/polyfill | ||
// that may be a bug copied from node, maybe the constructor should use | ||
// `code` not `errno`? nodejs/node#41104 | ||
let message = `${prefix}: ${context.syscall} returned ` + | ||
`${context.code} (${context.message})` | ||
|
||
if (context.path !== undefined) { | ||
message += ` ${context.path}` | ||
} | ||
if (context.dest !== undefined) { | ||
message += ` => ${context.dest}` | ||
} | ||
|
||
this.code = code | ||
Object.defineProperties(this, { | ||
name: { | ||
value: 'SystemError', | ||
enumerable: false, | ||
writable: true, | ||
configurable: true, | ||
}, | ||
message: { | ||
value: message, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true, | ||
}, | ||
info: { | ||
value: context, | ||
enumerable: true, | ||
configurable: true, | ||
writable: false, | ||
}, | ||
errno: { | ||
get () { | ||
return context.errno | ||
}, | ||
set (value) { | ||
context.errno = value | ||
}, | ||
enumerable: true, | ||
configurable: true, | ||
}, | ||
syscall: { | ||
get () { | ||
return context.syscall | ||
}, | ||
set (value) { | ||
context.syscall = value | ||
}, | ||
enumerable: true, | ||
configurable: true, | ||
}, | ||
}) | ||
|
||
if (context.path !== undefined) { | ||
Object.defineProperty(this, 'path', { | ||
get () { | ||
return context.path | ||
}, | ||
set (value) { | ||
context.path = value | ||
}, | ||
enumerable: true, | ||
configurable: true, | ||
}) | ||
} | ||
|
||
if (context.dest !== undefined) { | ||
Object.defineProperty(this, 'dest', { | ||
get () { | ||
return context.dest | ||
}, | ||
set (value) { | ||
context.dest = value | ||
}, | ||
enumerable: true, | ||
configurable: true, | ||
}) | ||
} | ||
} | ||
|
||
toString () { | ||
return `${this.name} [${this.code}]: ${this.message}` | ||
} | ||
|
||
[Symbol.for('nodejs.util.inspect.custom')] (_recurseTimes, ctx) { | ||
return inspect(this, { | ||
...ctx, | ||
getters: true, | ||
customInspect: false, | ||
}) | ||
} | ||
} | ||
|
||
function E (code, message) { | ||
module.exports[code] = class NodeError extends SystemError { | ||
constructor (ctx) { | ||
super(code, message, ctx) | ||
} | ||
} | ||
} | ||
|
||
E('ERR_FS_CP_DIR_TO_NON_DIR', 'Cannot overwrite directory with non-directory') | ||
E('ERR_FS_CP_EEXIST', 'Target already exists') | ||
E('ERR_FS_CP_EINVAL', 'Invalid src or dest') | ||
E('ERR_FS_CP_FIFO_PIPE', 'Cannot copy a FIFO pipe') | ||
E('ERR_FS_CP_NON_DIR_TO_DIR', 'Cannot overwrite non-directory with directory') | ||
E('ERR_FS_CP_SOCKET', 'Cannot copy a socket file') | ||
E('ERR_FS_CP_SYMLINK_TO_SUBDIRECTORY', 'Cannot overwrite symlink in subdirectory of self') | ||
E('ERR_FS_CP_UNKNOWN', 'Cannot copy an unknown file type') | ||
E('ERR_FS_EISDIR', 'Path is a directory') | ||
|
||
module.exports.ERR_INVALID_ARG_TYPE = class ERR_INVALID_ARG_TYPE extends Error { | ||
constructor (name, expected, actual) { | ||
super() | ||
this.code = 'ERR_INVALID_ARG_TYPE' | ||
this.message = `The ${name} argument must be ${expected}. Received ${typeof actual}` | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
node_modules/cacache/node_modules/@npmcli/fs/lib/cp/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const fs = require('fs/promises') | ||
const getOptions = require('../common/get-options.js') | ||
const node = require('../common/node.js') | ||
const polyfill = require('./polyfill.js') | ||
|
||
// node 16.7.0 added fs.cp | ||
const useNative = node.satisfies('>=16.7.0') | ||
|
||
const cp = async (src, dest, opts) => { | ||
const options = getOptions(opts, { | ||
copy: ['dereference', 'errorOnExist', 'filter', 'force', 'preserveTimestamps', 'recursive'], | ||
}) | ||
|
||
// the polyfill is tested separately from this module, no need to hack | ||
// process.version to try to trigger it just for coverage | ||
// istanbul ignore next | ||
return useNative | ||
? fs.cp(src, dest, options) | ||
: polyfill(src, dest, options) | ||
} | ||
|
||
module.exports = cp |
Oops, something went wrong.