Initial import from local backup (Documents-Playground/pakerpale)
This commit is contained in:
40
node_modules/remove/.npmignore
generated
vendored
Normal file
40
node_modules/remove/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
# git-ls-files --others --exclude-from=.git/info/exclude
|
||||
|
||||
# Source Control
|
||||
.git
|
||||
.svn
|
||||
.hg
|
||||
|
||||
# OSX
|
||||
.VolumeIcon.icns
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
.DS_Store
|
||||
._*
|
||||
Icon?
|
||||
|
||||
|
||||
# Junk
|
||||
*~
|
||||
*.sw?
|
||||
*.pid
|
||||
*.db
|
||||
*.sqlite
|
||||
# *.log
|
||||
*.[oa]
|
||||
|
||||
|
||||
# Node
|
||||
npm-debug.log
|
||||
node_modules/
|
||||
node_modules/*
|
||||
test/*.log
|
||||
test/fixtures/*.json
|
||||
test/fixtures/logs/*.log
|
||||
lib-cov/
|
||||
*.sass-cache
|
||||
# *.cache
|
||||
|
||||
# Project
|
||||
tmp
|
||||
72
node_modules/remove/README.md
generated
vendored
Normal file
72
node_modules/remove/README.md
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
# node-remove
|
||||
|
||||
Sync and async versions of `rm -r`, handling both files and directories (something astonishingly missing from `fs`).
|
||||
|
||||
````js
|
||||
var remove = require('remove');
|
||||
|
||||
// Asynchronous
|
||||
remove('/home/esr', function(err){
|
||||
if (err) console.error(err);
|
||||
else console.log('success!');
|
||||
});
|
||||
|
||||
// Synchronous
|
||||
try {
|
||||
remove.removeSync('/home/esr');
|
||||
console.log('success!');
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
````
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
Via [npm](http://npmjs.org/):
|
||||
|
||||
````sh
|
||||
npm install remove
|
||||
````
|
||||
|
||||
Or if you want to hack on the source:
|
||||
|
||||
````sh
|
||||
git clone https://github.com/dsc/node-remove.git
|
||||
cd node-remove
|
||||
npm link
|
||||
````
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### remove(paths, [options], cb) -> void
|
||||
### remove.removeAsync(paths, [options], cb) -> void
|
||||
|
||||
Asynchronously and recursively remove files and/or directories.
|
||||
|
||||
- **paths** *String | Array<String>* — Path or paths to remove.
|
||||
- **options** *Object* — Options object:
|
||||
- **verbose** : `false` *Boolean* — Log all errors and print each path just before it's removed.
|
||||
- **sequential** : `false` *Boolean* — If true, remove the supplied paths sequentially, such that an unsuppressed error would short-circuit further deletes.
|
||||
- **ignoreErrors** : `false` *Boolean* — If false, halt as soon as possible after an error occurs and invoke the callback. When operating in `sequential` mode, this implies an error removing the first of several paths would halt before touching the rest. If set, `ignoreErrors` overrides `ignoreMissing`.
|
||||
- **ignoreMissing** : `false` *Boolean* — Whether to treat missing paths as errors.
|
||||
- **callback** *Function* — Completion callback, invoked with null on success and the error on failure.
|
||||
|
||||
|
||||
### removeSync(paths, [options]) -> void
|
||||
|
||||
Synchronously and recursively remove files and/or directories.
|
||||
|
||||
- **paths** *String | Array<String>* — Path or paths to remove.
|
||||
- **options** *Object* — Options (all optional):
|
||||
- **verbose** : `false` *Boolean* — Log all errors and print each path just before it's removed.
|
||||
- **ignoreErrors** : `false` *Boolean* — If false, halt as soon as possible after an error occurs and invoke the callback. This implies an error removing the first of several paths would halt before touching the rest. If set, `ignoreErrors` overrides `ignoreMissing`.
|
||||
- **ignoreMissing** : `false` *Boolean* — Whether to treat missing paths as errors.
|
||||
|
||||
|
||||
## Feedback
|
||||
|
||||
Find a bug or want to contribute? Open a ticket on [github](http://github.com/dsc/node-remove).
|
||||
You're also welcome to send me email at [dsc@less.ly](mailto:dsc@less.ly?subject=node-remove).
|
||||
|
||||
1
node_modules/remove/index.js
generated
vendored
Normal file
1
node_modules/remove/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = exports = require('./remove');
|
||||
23
node_modules/remove/package.co
generated
vendored
Normal file
23
node_modules/remove/package.co
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
name : 'remove'
|
||||
version : '0.1.5'
|
||||
description : 'Sync and async rm -r.'
|
||||
homepage : 'http://github.com/dsc/node-remove'
|
||||
keywords : <[ util server files fs rm remove delete recursive ]>
|
||||
author : 'David Schoonover <dsc@less.ly> (http://less.ly)'
|
||||
|
||||
# main : './remove'
|
||||
# directories : lib: './lib', bin:'./bin', doc:'./doc', man:'./man'
|
||||
|
||||
dependencies :
|
||||
'seq' : '>= 0.3.5'
|
||||
devDependencies :
|
||||
'coco' : '>= 0.7.0'
|
||||
'expresso' : '>= 0.9.2'
|
||||
'mkdirp' : '>= 0.3.2'
|
||||
|
||||
scripts : test:'expresso'
|
||||
repository : type:'git', url:'git://github.com/dsc/node-remove.git'
|
||||
bugs : url:'http://github.com/dsc/node-remove/issues'
|
||||
|
||||
engine : node:'>=0.6.2'
|
||||
license : 'MIT'
|
||||
69
node_modules/remove/package.json
generated
vendored
Normal file
69
node_modules/remove/package.json
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"_from": "remove",
|
||||
"_id": "remove@0.1.5",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-CV/9gn1lyfQa2X0z5BanWBEHmVU=",
|
||||
"_location": "/remove",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "remove",
|
||||
"name": "remove",
|
||||
"escapedName": "remove",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/remove/-/remove-0.1.5.tgz",
|
||||
"_shasum": "095ffd827d65c9f41ad97d33e416a75811079955",
|
||||
"_spec": "remove",
|
||||
"_where": "D:\\dev\\crossmap\\backend-services\\cm-amazon-crawler",
|
||||
"author": {
|
||||
"name": "David Schoonover",
|
||||
"email": "dsc@less.ly",
|
||||
"url": "http://less.ly"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "http://github.com/dsc/node-remove/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"seq": ">= 0.3.5"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Sync and async rm -r.",
|
||||
"devDependencies": {
|
||||
"coco": ">= 0.7.0",
|
||||
"expresso": ">= 0.9.2",
|
||||
"mkdirp": ">= 0.3.2"
|
||||
},
|
||||
"engine": {
|
||||
"node": ">=0.6.2"
|
||||
},
|
||||
"homepage": "http://github.com/dsc/node-remove",
|
||||
"keywords": [
|
||||
"util",
|
||||
"server",
|
||||
"files",
|
||||
"fs",
|
||||
"rm",
|
||||
"remove",
|
||||
"delete",
|
||||
"recursive"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "remove",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/dsc/node-remove.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "expresso"
|
||||
},
|
||||
"version": "0.1.5"
|
||||
}
|
||||
116
node_modules/remove/remove.co
generated
vendored
Normal file
116
node_modules/remove/remove.co
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
{exists, existsSync} = path
|
||||
|
||||
Seq = require 'seq'
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Asynchronously and recursively remove files and/or directories.
|
||||
*
|
||||
* @param {String|Array<String>} paths Path or paths to remove.
|
||||
* @param {Object} [options] Options:
|
||||
* @param {Boolean} [options.verbose=false] Log all errors and print each path
|
||||
* just before it's removed.
|
||||
* @param {Boolean} [options.sequential=false] If true, remove the supplied
|
||||
* paths sequentially, such that an unsuppressed error would short-circuit
|
||||
* further deletes.
|
||||
* @param {Boolean} [options.ignoreErrors=false] If false, halt as soon as
|
||||
* possible after an error occurs and invoke the callback. When operating
|
||||
* in `sequential` mode, this implies an error removing the first of several
|
||||
* paths would halt before touching the rest. If set, `ignoreErrors` overrides
|
||||
* `ignoreMissing`.
|
||||
* @param {Boolean} [options.ignoreMissing=false] Whether to treat missing
|
||||
* paths as errors.
|
||||
* @param {Function} cb Completion callback, invoked with null on success
|
||||
* and the error on failure.
|
||||
* @returns {void}
|
||||
*/
|
||||
removeAsync = module.exports = exports = \
|
||||
function removeAsync (paths=[], options, cb)
|
||||
paths = [paths] if typeof paths is 'string'
|
||||
if typeof options is 'function'
|
||||
[cb, options] = [options, {}]
|
||||
if typeof cb is not 'function'
|
||||
throw new Error 'Callback must be a function!'
|
||||
options = {verbose, ignoreErrors, ignoreMissing} =
|
||||
({-verbose, -sequential, -ignoreErrors, -ignoreMissing} import options)
|
||||
# TODO: recurisve? maxdepth?
|
||||
|
||||
stepMethod = if options.sequential then 'seqEach_' else 'parEach_'
|
||||
Seq(paths)[stepMethod] (next_path, p) ->
|
||||
console.log "rm -rv #p" if verbose
|
||||
Seq()
|
||||
.seq fs.lstat, p, Seq
|
||||
.seq (stats) ->
|
||||
# Files/links can be removed right away, and then move on to the next path
|
||||
if stats.isSymbolicLink() or not stats.isDirectory()
|
||||
fs.unlink p, next_path
|
||||
else
|
||||
# ...But directories need to be empty
|
||||
fs.readdir p, this
|
||||
# Remove children with the same options
|
||||
.seq (contents) -> removeAsync contents.map(-> path.join p, it), options, this
|
||||
# Finally, kill it
|
||||
.seq fs.rmdir, p, Seq
|
||||
# And terminate the async chain
|
||||
.seq next_path.ok
|
||||
# Propagate errors
|
||||
.catch (err) -> next_path err
|
||||
|
||||
# Notify callback!
|
||||
.seq -> cb null
|
||||
.catch (err) ->
|
||||
console.error err if verbose
|
||||
return @ok() if ignoreErrors or (ignoreMissing and err.code is 'ENOENT')
|
||||
cb err
|
||||
|
||||
void
|
||||
|
||||
exports.removeAsync = removeAsync
|
||||
|
||||
|
||||
/**
|
||||
* Synchronously and recursively remove files and/or directories.
|
||||
*
|
||||
* @param {String|Array<String>} paths Path or paths to remove.
|
||||
* @param {Object} [options] Options:
|
||||
* @param {Boolean} [options.verbose=false] Log all errors and print each path
|
||||
* just before it's removed.
|
||||
* @param {Boolean} [options.ignoreErrors=false] If false, halt as soon as
|
||||
* possible after an error occurs and invoke the callback. This implies an error
|
||||
* removing the first of several paths would halt before touching the rest. If
|
||||
* set, `ignoreErrors` overrides `ignoreMissing`.
|
||||
* @param {Boolean} [options.ignoreMissing=false] Whether to treat missing
|
||||
* paths as errors.
|
||||
* @returns {void}
|
||||
*/
|
||||
removeSync = exports.removeSync = \
|
||||
function removeSync(paths=[], options={})
|
||||
paths = [paths] if typeof paths is 'string'
|
||||
options = {verbose, ignoreErrors, ignoreMissing} =
|
||||
({-verbose, -ignoreErrors, -ignoreMissing} import options)
|
||||
|
||||
for p of paths
|
||||
console.log "rm -rv #p" if verbose
|
||||
try
|
||||
stats = fs.lstatSync p
|
||||
|
||||
# files can be removed right away
|
||||
if stats.isSymbolicLink() or not stats.isDirectory()
|
||||
fs.unlinkSync p
|
||||
else
|
||||
# directories need to be empty
|
||||
fs.readdirSync p .forEach -> removeSync path.join(p,it), options
|
||||
|
||||
# finally, kill it
|
||||
fs.rmdirSync p
|
||||
catch err
|
||||
console.error err if verbose
|
||||
if ignoreErrors or (ignoreMissing and err.code is 'ENOENT')
|
||||
continue
|
||||
else
|
||||
throw err
|
||||
void
|
||||
|
||||
141
node_modules/remove/remove.js
generated
vendored
Normal file
141
node_modules/remove/remove.js
generated
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
var fs, path, exists, existsSync, Seq, exports, removeAsync, removeSync;
|
||||
fs = require('fs');
|
||||
path = require('path');
|
||||
exists = path.exists, existsSync = path.existsSync;
|
||||
Seq = require('seq');
|
||||
/**
|
||||
* Asynchronously and recursively remove files and/or directories.
|
||||
*
|
||||
* @param {String|Array<String>} paths Path or paths to remove.
|
||||
* @param {Object} [options] Options:
|
||||
* @param {Boolean} [options.verbose=false] Log all errors and print each path
|
||||
* just before it's removed.
|
||||
* @param {Boolean} [options.sequential=false] If true, remove the supplied
|
||||
* paths sequentially, such that an unsuppressed error would short-circuit
|
||||
* further deletes.
|
||||
* @param {Boolean} [options.ignoreErrors=false] If false, halt as soon as
|
||||
* possible after an error occurs and invoke the callback. When operating
|
||||
* in `sequential` mode, this implies an error removing the first of several
|
||||
* paths would halt before touching the rest. If set, `ignoreErrors` overrides
|
||||
* `ignoreMissing`.
|
||||
* @param {Boolean} [options.ignoreMissing=false] Whether to treat missing
|
||||
* paths as errors.
|
||||
* @param {Function} cb Completion callback, invoked with null on success
|
||||
* and the error on failure.
|
||||
* @returns {void}
|
||||
*/
|
||||
removeAsync = module.exports = exports = (function(){
|
||||
function removeAsync(paths, options, cb){
|
||||
var verbose, ignoreErrors, ignoreMissing, stepMethod, __ref;
|
||||
paths == null && (paths = []);
|
||||
if (typeof paths === 'string') {
|
||||
paths = [paths];
|
||||
}
|
||||
if (typeof options === 'function') {
|
||||
__ref = [options, {}], cb = __ref[0], options = __ref[1];
|
||||
}
|
||||
if (typeof cb !== 'function') {
|
||||
throw new Error('Callback must be a function!');
|
||||
}
|
||||
options = (__ref = __import({
|
||||
verbose: false,
|
||||
sequential: false,
|
||||
ignoreErrors: false,
|
||||
ignoreMissing: false
|
||||
}, options), verbose = __ref.verbose, ignoreErrors = __ref.ignoreErrors, ignoreMissing = __ref.ignoreMissing, __ref);
|
||||
stepMethod = options.sequential ? 'seqEach_' : 'parEach_';
|
||||
Seq(paths)[stepMethod](function(next_path, p){
|
||||
if (verbose) {
|
||||
console.log("rm -rv " + p);
|
||||
}
|
||||
return Seq().seq(fs.lstat, p, Seq).seq(function(stats){
|
||||
if (stats.isSymbolicLink() || !stats.isDirectory()) {
|
||||
return fs.unlink(p, next_path);
|
||||
} else {
|
||||
return fs.readdir(p, this);
|
||||
}
|
||||
}).seq(function(contents){
|
||||
return removeAsync(contents.map(function(it){
|
||||
return path.join(p, it);
|
||||
}), options, this);
|
||||
}).seq(fs.rmdir, p, Seq).seq(next_path.ok)['catch'](function(err){
|
||||
return next_path(err);
|
||||
});
|
||||
}).seq(function(){
|
||||
return cb(null);
|
||||
})['catch'](function(err){
|
||||
if (verbose) {
|
||||
console.error(err);
|
||||
}
|
||||
if (ignoreErrors || (ignoreMissing && err.code === 'ENOENT')) {
|
||||
return this.ok();
|
||||
}
|
||||
return cb(err);
|
||||
});
|
||||
}
|
||||
return removeAsync;
|
||||
}());
|
||||
exports.removeAsync = removeAsync;
|
||||
/**
|
||||
* Synchronously and recursively remove files and/or directories.
|
||||
*
|
||||
* @param {String|Array<String>} paths Path or paths to remove.
|
||||
* @param {Object} [options] Options:
|
||||
* @param {Boolean} [options.verbose=false] Log all errors and print each path
|
||||
* just before it's removed.
|
||||
* @param {Boolean} [options.ignoreErrors=false] If false, halt as soon as
|
||||
* possible after an error occurs and invoke the callback. This implies an error
|
||||
* removing the first of several paths would halt before touching the rest. If
|
||||
* set, `ignoreErrors` overrides `ignoreMissing`.
|
||||
* @param {Boolean} [options.ignoreMissing=false] Whether to treat missing
|
||||
* paths as errors.
|
||||
* @returns {void}
|
||||
*/
|
||||
removeSync = exports.removeSync = (function(){
|
||||
function removeSync(paths, options){
|
||||
var verbose, ignoreErrors, ignoreMissing, p, stats, __ref, __i, __len;
|
||||
paths == null && (paths = []);
|
||||
options == null && (options = {});
|
||||
if (typeof paths === 'string') {
|
||||
paths = [paths];
|
||||
}
|
||||
options = (__ref = __import({
|
||||
verbose: false,
|
||||
ignoreErrors: false,
|
||||
ignoreMissing: false
|
||||
}, options), verbose = __ref.verbose, ignoreErrors = __ref.ignoreErrors, ignoreMissing = __ref.ignoreMissing, __ref);
|
||||
for (__i = 0, __len = paths.length; __i < __len; ++__i) {
|
||||
p = paths[__i];
|
||||
if (verbose) {
|
||||
console.log("rm -rv " + p);
|
||||
}
|
||||
try {
|
||||
stats = fs.lstatSync(p);
|
||||
if (stats.isSymbolicLink() || !stats.isDirectory()) {
|
||||
fs.unlinkSync(p);
|
||||
} else {
|
||||
fs.readdirSync(p).forEach(__fn);
|
||||
fs.rmdirSync(p);
|
||||
}
|
||||
} catch (err) {
|
||||
if (verbose) {
|
||||
console.error(err);
|
||||
}
|
||||
if (ignoreErrors || (ignoreMissing && err.code === 'ENOENT')) {
|
||||
continue;
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
function __fn(it){
|
||||
return removeSync(path.join(p, it), options);
|
||||
}
|
||||
}
|
||||
return removeSync;
|
||||
}());
|
||||
function __import(obj, src){
|
||||
var own = {}.hasOwnProperty;
|
||||
for (var key in src) if (own.call(src, key)) obj[key] = src[key];
|
||||
return obj;
|
||||
}
|
||||
66
node_modules/remove/test.co
generated
vendored
Normal file
66
node_modules/remove/test.co
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env coco
|
||||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
Seq = require 'seq'
|
||||
mkdirp = require 'mkdirp'
|
||||
|
||||
{removeAsync, removeSync} = require 'remove'
|
||||
|
||||
|
||||
touch = (f, cb) ->
|
||||
return cb null if path.existsSync f
|
||||
fs.writeFile f, '', 'utf8', cb
|
||||
|
||||
setup_tests = (cb) ->
|
||||
Seq()
|
||||
.seq mkdirp, 'tmp/d1', 8r755, Seq
|
||||
.set <[ tmp/f1 tmp/f2 tmp/d1/f3 tmp/d1/f4 ]>
|
||||
.parEach -> touch it, this
|
||||
.seq mkdirp, 'tmp/d2/d3', 8r755, Seq
|
||||
.set <[ tmp/d2/f5 tmp/d2/f6 tmp/d2/d3/f7 tmp/d2/d3/f8 ]>
|
||||
.parEach -> touch it, this
|
||||
.seq mkdirp, 'tmp/d4/d5/d6', 8r755, Seq
|
||||
.set <[ tmp/d4/d5/d6/f9 tmp/d4/d5/d6/f10 tmp/d4/d5/d6/f11 tmp/d4/d5/d6/f12 ]>
|
||||
.parEach -> touch it, this
|
||||
.seq mkdirp, 'tmp/d7', 8r755, Seq
|
||||
.seq -> cb()
|
||||
|
||||
|
||||
###
|
||||
|
||||
console.log '\n### removeSync Tests ###'
|
||||
<- setup_tests
|
||||
|
||||
console.log "\nremoveSync <[ tmp/f1 tmp/d1 tmp/f2 ]>"
|
||||
removeSync <[ tmp/f1 tmp/d1 tmp/f2 ]>, {+verbose}
|
||||
|
||||
console.log "\nremoveSync 'tmp/d2'"
|
||||
removeSync 'tmp/d2', {+verbose}
|
||||
|
||||
console.log "\nremoveSync <[ tmp/d4 tmp/d7 ]>"
|
||||
removeSync <[ tmp/d4 tmp/d7 ]>, {+verbose}
|
||||
|
||||
contents <- fs.readdir 'tmp'
|
||||
throw new Error("Failed to remove all files: #{contents.join ', '}") if contents?.length
|
||||
|
||||
|
||||
###
|
||||
|
||||
console.log '\n### removeAsync Tests ###'
|
||||
<- setup_tests
|
||||
|
||||
console.log "\nremoveAsync <[ tmp/f1 tmp/d1 tmp/f2 ]>"
|
||||
err <- removeAsync <[ tmp/f1 tmp/d1 tmp/f2 ]>, {+verbose}
|
||||
throw err if err
|
||||
|
||||
console.log "\nremoveAsync 'tmp/d2'"
|
||||
err <- removeAsync 'tmp/d2', {+verbose}
|
||||
throw err if err
|
||||
|
||||
console.log "\nremoveAsync <[ tmp/d4 tmp/d7 ]>"
|
||||
err <- removeAsync <[ tmp/d4 tmp/d7 ]>, {+verbose}
|
||||
throw err if err
|
||||
|
||||
contents <- fs.readdir 'tmp'
|
||||
throw new Error("Failed to remove all files: #{contents.join ', '}") if contents?.length
|
||||
|
||||
Reference in New Issue
Block a user