updated npm modules
This commit is contained in:
38
node_modules/del/index.js
generated
vendored
38
node_modules/del/index.js
generated
vendored
@@ -11,29 +11,27 @@ const rimrafP = pify(rimraf);
|
||||
|
||||
function safeCheck(file) {
|
||||
if (isPathCwd(file)) {
|
||||
throw new Error('Cannot delete the current working directory. Can be overriden with the `force` option.');
|
||||
throw new Error('Cannot delete the current working directory. Can be overridden with the `force` option.');
|
||||
}
|
||||
|
||||
if (!isPathInCwd(file)) {
|
||||
throw new Error('Cannot delete files/folders outside the current working directory. Can be overriden with the `force` option.');
|
||||
throw new Error('Cannot delete files/folders outside the current working directory. Can be overridden with the `force` option.');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = (patterns, opts) => {
|
||||
opts = Object.assign({}, opts);
|
||||
const del = (patterns, options) => {
|
||||
options = Object.assign({}, options);
|
||||
|
||||
const force = opts.force;
|
||||
delete opts.force;
|
||||
|
||||
const dryRun = opts.dryRun;
|
||||
delete opts.dryRun;
|
||||
const {force, dryRun} = options;
|
||||
delete options.force;
|
||||
delete options.dryRun;
|
||||
|
||||
const mapper = file => {
|
||||
if (!force) {
|
||||
safeCheck(file);
|
||||
}
|
||||
|
||||
file = path.resolve(opts.cwd || '', file);
|
||||
file = path.resolve(options.cwd || '', file);
|
||||
|
||||
if (dryRun) {
|
||||
return file;
|
||||
@@ -42,24 +40,26 @@ module.exports = (patterns, opts) => {
|
||||
return rimrafP(file, {glob: false}).then(() => file);
|
||||
};
|
||||
|
||||
return globby(patterns, opts).then(files => pMap(files, mapper, opts));
|
||||
return globby(patterns, options).then(files => pMap(files, mapper, options));
|
||||
};
|
||||
|
||||
module.exports.sync = (patterns, opts) => {
|
||||
opts = Object.assign({}, opts);
|
||||
module.exports = del;
|
||||
// TODO: Remove this for the next major release
|
||||
module.exports.default = del;
|
||||
|
||||
const force = opts.force;
|
||||
delete opts.force;
|
||||
module.exports.sync = (patterns, options) => {
|
||||
options = Object.assign({}, options);
|
||||
|
||||
const dryRun = opts.dryRun;
|
||||
delete opts.dryRun;
|
||||
const {force, dryRun} = options;
|
||||
delete options.force;
|
||||
delete options.dryRun;
|
||||
|
||||
return globby.sync(patterns, opts).map(file => {
|
||||
return globby.sync(patterns, options).map(file => {
|
||||
if (!force) {
|
||||
safeCheck(file);
|
||||
}
|
||||
|
||||
file = path.resolve(opts.cwd || '', file);
|
||||
file = path.resolve(options.cwd || '', file);
|
||||
|
||||
if (!dryRun) {
|
||||
rimraf.sync(file, {glob: false});
|
||||
|
||||
Reference in New Issue
Block a user