diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-10-10 03:43:44 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-10-10 03:43:44 +0200 |
commit | abd94a7f5a50f43c797a11b53549ae48fff667c3 (patch) | |
tree | ab8ed457f65cdd72e13e0571d2975729428f1551 /node_modules/del | |
parent | a0247c6a3fd6a09a41a7e35a3441324c4dcb58be (diff) | |
download | wallet-core-abd94a7f5a50f43c797a11b53549ae48fff667c3.tar.xz |
add node_modules to address #4364
Diffstat (limited to 'node_modules/del')
-rw-r--r-- | node_modules/del/index.js | 73 | ||||
-rw-r--r-- | node_modules/del/license | 21 | ||||
-rw-r--r-- | node_modules/del/package.json | 128 | ||||
-rw-r--r-- | node_modules/del/readme.md | 106 |
4 files changed, 328 insertions, 0 deletions
diff --git a/node_modules/del/index.js b/node_modules/del/index.js new file mode 100644 index 000000000..0ceff9629 --- /dev/null +++ b/node_modules/del/index.js @@ -0,0 +1,73 @@ +'use strict'; +var path = require('path'); +var globby = require('globby'); +var isPathCwd = require('is-path-cwd'); +var isPathInCwd = require('is-path-in-cwd'); +var objectAssign = require('object-assign'); +var Promise = require('pinkie-promise'); +var pify = require('pify'); +var rimraf = require('rimraf'); + +var rimrafP = pify(rimraf, Promise); + +function safeCheck(file) { + if (isPathCwd(file)) { + throw new Error('Cannot delete the current working directory. Can be overriden 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.'); + } +} + +module.exports = function (patterns, opts) { + opts = objectAssign({}, opts); + + var force = opts.force; + delete opts.force; + + var dryRun = opts.dryRun; + delete opts.dryRun; + + return globby(patterns, opts).then(function (files) { + return Promise.all(files.map(function (file) { + if (!force) { + safeCheck(file); + } + + file = path.resolve(opts.cwd || '', file); + + if (dryRun) { + return Promise.resolve(file); + } + + return rimrafP(file).then(function () { + return file; + }); + })); + }); +}; + +module.exports.sync = function (patterns, opts) { + opts = objectAssign({}, opts); + + var force = opts.force; + delete opts.force; + + var dryRun = opts.dryRun; + delete opts.dryRun; + + return globby.sync(patterns, opts).map(function (file) { + if (!force) { + safeCheck(file); + } + + file = path.resolve(opts.cwd || '', file); + + if (!dryRun) { + rimraf.sync(file); + } + + return file; + }); +}; diff --git a/node_modules/del/license b/node_modules/del/license new file mode 100644 index 000000000..654d0bfe9 --- /dev/null +++ b/node_modules/del/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +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. diff --git a/node_modules/del/package.json b/node_modules/del/package.json new file mode 100644 index 000000000..d0539f027 --- /dev/null +++ b/node_modules/del/package.json @@ -0,0 +1,128 @@ +{ + "_args": [ + [ + { + "raw": "del@^2.2.0", + "scope": null, + "escapedName": "del", + "name": "del", + "rawSpec": "^2.2.0", + "spec": ">=2.2.0 <3.0.0", + "type": "range" + }, + "/home/dold/repos/taler/wallet-webex" + ] + ], + "_from": "del@>=2.2.0 <3.0.0", + "_id": "del@2.2.2", + "_inCache": true, + "_location": "/del", + "_nodeVersion": "4.4.5", + "_npmOperationalInternal": { + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/del-2.2.2.tgz_1471046735537_0.4419694794341922" + }, + "_npmUser": { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + "_npmVersion": "2.15.5", + "_phantomChildren": {}, + "_requested": { + "raw": "del@^2.2.0", + "scope": null, + "escapedName": "del", + "name": "del", + "rawSpec": "^2.2.0", + "spec": ">=2.2.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "#DEV:/" + ], + "_resolved": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", + "_shasum": "c12c981d067846c84bcaf862cff930d907ffd1a8", + "_shrinkwrap": null, + "_spec": "del@^2.2.0", + "_where": "/home/dold/repos/taler/wallet-webex", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/del/issues" + }, + "dependencies": { + "globby": "^5.0.0", + "is-path-cwd": "^1.0.0", + "is-path-in-cwd": "^1.0.0", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0", + "rimraf": "^2.2.8" + }, + "description": "Delete files and folders", + "devDependencies": { + "ava": "*", + "fs-extra": "^0.30.0", + "path-exists": "^2.0.0", + "tempfile": "^1.1.1", + "xo": "*" + }, + "directories": {}, + "dist": { + "shasum": "c12c981d067846c84bcaf862cff930d907ffd1a8", + "tarball": "https://registry.npmjs.org/del/-/del-2.2.2.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "3a97a5ba131055fbf7eb39f5ed47db86a2fd4497", + "homepage": "https://github.com/sindresorhus/del#readme", + "keywords": [ + "delete", + "del", + "remove", + "destroy", + "trash", + "unlink", + "clean", + "cleaning", + "cleanup", + "rm", + "rmrf", + "rimraf", + "rmdir", + "glob", + "gulpfriendly", + "file", + "files", + "folder", + "dir", + "directory", + "fs", + "filesystem" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "del", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/del.git" + }, + "scripts": { + "test": "xo && ava" + }, + "version": "2.2.2" +} diff --git a/node_modules/del/readme.md b/node_modules/del/readme.md new file mode 100644 index 000000000..c0c121923 --- /dev/null +++ b/node_modules/del/readme.md @@ -0,0 +1,106 @@ +# del [![Build Status](https://travis-ci.org/sindresorhus/del.svg?branch=master)](https://travis-ci.org/sindresorhus/del) + +> Delete files and folders using [globs](https://github.com/isaacs/minimatch#usage) + +Pretty much [rimraf](https://github.com/isaacs/rimraf) with a Promise API and support for multiple files and globbing. It also protects you against deleting the current working directory and above. + +--- + +<p align="center"><b>🔥 Want to strengthen your core JavaScript skills and master ES6?</b><br>I would personally recommend this awesome <a href="https://ES6.io/friend/AWESOME">ES6 course</a> by Wes Bos.</p> + +--- + + +## Install + +``` +$ npm install --save del +``` + + +## Usage + +```js +const del = require('del'); + +del(['tmp/*.js', '!tmp/unicorn.js']).then(paths => { + console.log('Deleted files and folders:\n', paths.join('\n')); +}); +``` + + +## Beware + +The glob pattern `**` matches all children and *the parent*. + +So this won't work: + +```js +del.sync(['public/assets/**', '!public/assets/goat.png']); +``` + +You have to explicitly ignore the parent directories too: + +```js +del.sync(['public/assets/**', '!public/assets', '!public/assets/goat.png']); +``` + +Suggestions on how to improve this welcome! + + +## API + +### del(patterns, [options]) + +Returns a promise for an array of deleted paths. + +### del.sync(patterns, [options]) + +Returns an array of deleted paths. + +#### patterns + +Type: `string`, `array` + +See supported minimatch [patterns](https://github.com/isaacs/minimatch#usage). + +- [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/master/test.js) +- [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns) + +#### options + +Type: `object` + +See the `node-glob` [options](https://github.com/isaacs/node-glob#options). + +##### force + +Type: `boolean` +Default: `false` + +Allow deleting the current working directory and outside. + +##### dryRun + +Type: `boolean` +Default: `false` + +See what would be deleted. + +```js +const del = require('del'); + +del(['tmp/*.js'], {dryRun: true}).then(paths => { + console.log('Files and folders that would be deleted:\n', paths.join('\n')); +}); +``` + + +## CLI + +See [del-cli](https://github.com/sindresorhus/del-cli) for a CLI for this module and [trash-cli](https://github.com/sindresorhus/trash-cli) for a safe version that is suitable for running by hand. + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) |