mirror of
https://github.com/fooflington/selfdefined.git
synced 2025-06-10 21:01:41 +00:00
update
This commit is contained in:
73
node_modules/del/index.js
generated
vendored
Normal file
73
node_modules/del/index.js
generated
vendored
Normal file
@ -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;
|
||||
});
|
||||
};
|
21
node_modules/del/license
generated
vendored
Normal file
21
node_modules/del/license
generated
vendored
Normal file
@ -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.
|
96
node_modules/del/package.json
generated
vendored
Normal file
96
node_modules/del/package.json
generated
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"del@2.2.2",
|
||||
"/Users/tatiana/selfdefined"
|
||||
]
|
||||
],
|
||||
"_from": "del@2.2.2",
|
||||
"_id": "del@2.2.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=",
|
||||
"_location": "/del",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "del@2.2.2",
|
||||
"name": "del",
|
||||
"escapedName": "del",
|
||||
"rawSpec": "2.2.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.2.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/recursive-copy"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/del/-/del-2.2.2.tgz",
|
||||
"_spec": "2.2.2",
|
||||
"_where": "/Users/tatiana/selfdefined",
|
||||
"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": "*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"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",
|
||||
"name": "del",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sindresorhus/del.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"version": "2.2.2"
|
||||
}
|
106
node_modules/del/readme.md
generated
vendored
Normal file
106
node_modules/del/readme.md
generated
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
# del [](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)
|
Reference in New Issue
Block a user