diff options
Diffstat (limited to 'node_modules/move-concurrently')
| -rw-r--r-- | node_modules/move-concurrently/LICENSE | 14 | ||||
| -rw-r--r-- | node_modules/move-concurrently/README.md | 53 | ||||
| -rw-r--r-- | node_modules/move-concurrently/move.js | 84 | ||||
| l--------- | node_modules/move-concurrently/node_modules/.bin/mkdirp | 1 | ||||
| l--------- | node_modules/move-concurrently/node_modules/.bin/rimraf | 1 | ||||
| -rw-r--r-- | node_modules/move-concurrently/package.json | 42 |
6 files changed, 195 insertions, 0 deletions
diff --git a/node_modules/move-concurrently/LICENSE b/node_modules/move-concurrently/LICENSE new file mode 100644 index 00000000..83e7c4c6 --- /dev/null +++ b/node_modules/move-concurrently/LICENSE @@ -0,0 +1,14 @@ +Copyright (c) 2017, Rebecca Turner <me@re-becca.org> + +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 THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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. + diff --git a/node_modules/move-concurrently/README.md b/node_modules/move-concurrently/README.md new file mode 100644 index 00000000..0e6e9b9e --- /dev/null +++ b/node_modules/move-concurrently/README.md @@ -0,0 +1,53 @@ +# move-concurrently + +Move files and directories. + +``` +const move = require('move-concurrently') +move('/path/to/thing', '/new/path/thing').then(() => { + // thing is now moved! +}).catch(err => { + // oh no! +}) +``` + +Uses `rename` to move things as fast as possible. + +If you `move` across devices or on filesystems that don't support renaming +large directories. That is, situations that result in `rename` returning +the `EXDEV` error, then `move` will fallback to copy + delete. + +When recursively copying directories it will first try to rename the +contents before falling back to copying. While this will be slightly slower +in true cross-device scenarios, it is MUCH faster in cases where the +filesystem can't handle directory renames. + +When copying ownership is maintained when running as root. Permissions are +always maintained. On Windows, if symlinks are unavailable then junctions +will be used. + +## INTERFACE + +### move(from, to, options) → Promise + +Recursively moves `from` to `to` and resolves its promise when finished. +If `to` already exists then the promise will be rejected with an `EEXIST` +error. + +Starts by trying to rename `from` to `to`. + +Options are: + +* maxConcurrency – (Default: `1`) The maximum number of concurrent copies to do at once. +* isWindows - (Default: `process.platform === 'win32'`) If true enables Windows symlink semantics. This requires + an extra `stat` to determine if the destination of a symlink is a file or directory. If symlinking a directory + fails then we'll try making a junction instead. + +Options can also include dependency injection: + +* Promise - (Default: `global.Promise`) The promise implementation to use, defaults to Node's. +* fs - (Default: `require('fs')`) The filesystem module to use. Can be used + to use `graceful-fs` or to inject a mock. +* writeStreamAtomic - (Default: `require('fs-write-stream-atomic')`) The + implementation of `writeStreamAtomic` to use. Used to inject a mock. +* getuid - (Default: `process.getuid`) A function that returns the current UID. Used to inject a mock. diff --git a/node_modules/move-concurrently/move.js b/node_modules/move-concurrently/move.js new file mode 100644 index 00000000..6a2a7332 --- /dev/null +++ b/node_modules/move-concurrently/move.js @@ -0,0 +1,84 @@ +'use strict' +module.exports = move + +var nodeFs = require('fs') +var rimraf = require('rimraf') +var validate = require('aproba') +var copy = require('copy-concurrently') +var RunQueue = require('run-queue') +var extend = Object.assign || require('util')._extend + +function promisify (Promise, fn) { + return function () { + var args = [].slice.call(arguments) + return new Promise(function (resolve, reject) { + return fn.apply(null, args.concat(function (err, value) { + if (err) { + reject(err) + } else { + resolve(value) + } + })) + }) + } +} + +function move (from, to, opts) { + validate('SSO|SS', arguments) + opts = extend({}, opts || {}) + + var Promise = opts.Promise || global.Promise + var fs = opts.fs || nodeFs + var rimrafAsync = promisify(Promise, rimraf) + var renameAsync = promisify(Promise, fs.rename) + + opts.top = from + + var queue = new RunQueue({ + maxConcurrency: opts.maxConcurrency, + Promise: Promise + }) + opts.queue = queue + opts.recurseWith = rename + + queue.add(0, rename, [from, to, opts]) + + return queue.run().then(function () { + return remove(from) + }, function (err) { + // if the target already exists don't clobber it + if (err.code === 'EEXIST' || err.code === 'EPERM') { + return passThroughError() + } else { + return remove(to).then(passThroughError, passThroughError) + } + function passThroughError () { + return Promise.reject(err) + } + }) + + function remove (target) { + var opts = { + unlink: fs.unlink, + chmod: fs.chmod, + stat: fs.stat, + lstat: fs.lstat, + rmdir: fs.rmdir, + readdir: fs.readdir, + glob: false + } + return rimrafAsync(target, opts) + } + + function rename (from, to, opts, done) { + return renameAsync(from, to).catch(function (err) { + if (err.code !== 'EXDEV') { + return Promise.reject(err) + } else { + return remove(to).then(function () { + return copy.item(from, to, opts) + }) + } + }) + } +} diff --git a/node_modules/move-concurrently/node_modules/.bin/mkdirp b/node_modules/move-concurrently/node_modules/.bin/mkdirp new file mode 120000 index 00000000..91a5f623 --- /dev/null +++ b/node_modules/move-concurrently/node_modules/.bin/mkdirp @@ -0,0 +1 @@ +../../../mkdirp/bin/cmd.js
\ No newline at end of file diff --git a/node_modules/move-concurrently/node_modules/.bin/rimraf b/node_modules/move-concurrently/node_modules/.bin/rimraf new file mode 120000 index 00000000..632d6da2 --- /dev/null +++ b/node_modules/move-concurrently/node_modules/.bin/rimraf @@ -0,0 +1 @@ +../../../rimraf/bin.js
\ No newline at end of file diff --git a/node_modules/move-concurrently/package.json b/node_modules/move-concurrently/package.json new file mode 100644 index 00000000..072a3ff9 --- /dev/null +++ b/node_modules/move-concurrently/package.json @@ -0,0 +1,42 @@ +{ + "name": "move-concurrently", + "version": "1.0.1", + "description": "Promises of moves of files or directories with rename, falling back to recursive rename/copy on EXDEV errors, with configurable concurrency and win32 junction support.", + "main": "move.js", + "scripts": { + "test": "standard && tap --coverage test" + }, + "keywords": [ + "move" + ], + "author": "Rebecca Turner <me@re-becca.org> (http://re-becca.org/)", + "license": "ISC", + "dependencies": { + "copy-concurrently": "^1.0.0", + "aproba": "^1.1.1", + "fs-write-stream-atomic": "^1.0.8", + "mkdirp": "^0.5.1", + "rimraf": "^2.5.4", + "run-queue": "^1.0.3" + }, + "devDependencies": { + "standard": "^8.6.0", + "tacks": "^1.2.6", + "tap": "^10.1.1" + }, + "files": [ + "move.js", + "is-windows.js" + ], + "directories": { + "test": "test" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/npm/move-concurrently.git" + }, + "bugs": { + "url": "https://github.com/npm/move-concurrently/issues" + }, + "homepage": "https://www.npmjs.com/package/move-concurrently" +} |
