Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
node_modules/aproba/ | 12-May-2024 | - | 279 | 232 | ||
LICENSE | D | 12-May-2024 | 752 | 15 | 11 | |
README.md | D | 12-May-2024 | 2 KiB | 54 | 39 | |
move.js | D | 12-May-2024 | 2 KiB | 85 | 73 | |
package.json | D | 12-May-2024 | 1.9 KiB | 78 | 77 |
README.md
1# move-concurrently 2 3Move files and directories. 4 5``` 6const move = require('move-concurrently') 7move('/path/to/thing', '/new/path/thing').then(() => { 8 // thing is now moved! 9}).catch(err => { 10 // oh no! 11}) 12``` 13 14Uses `rename` to move things as fast as possible. 15 16If you `move` across devices or on filesystems that don't support renaming 17large directories. That is, situations that result in `rename` returning 18the `EXDEV` error, then `move` will fallback to copy + delete. 19 20When recursively copying directories it will first try to rename the 21contents before falling back to copying. While this will be slightly slower 22in true cross-device scenarios, it is MUCH faster in cases where the 23filesystem can't handle directory renames. 24 25When copying ownership is maintained when running as root. Permissions are 26always maintained. On Windows, if symlinks are unavailable then junctions 27will be used. 28 29## INTERFACE 30 31### move(from, to, options) → Promise 32 33Recursively moves `from` to `to` and resolves its promise when finished. 34If `to` already exists then the promise will be rejected with an `EEXIST` 35error. 36 37Starts by trying to rename `from` to `to`. 38 39Options are: 40 41* maxConcurrency – (Default: `1`) The maximum number of concurrent copies to do at once. 42* isWindows - (Default: `process.platform === 'win32'`) If true enables Windows symlink semantics. This requires 43 an extra `stat` to determine if the destination of a symlink is a file or directory. If symlinking a directory 44 fails then we'll try making a junction instead. 45 46Options can also include dependency injection: 47 48* Promise - (Default: `global.Promise`) The promise implementation to use, defaults to Node's. 49* fs - (Default: `require('fs')`) The filesystem module to use. Can be used 50 to use `graceful-fs` or to inject a mock. 51* writeStreamAtomic - (Default: `require('fs-write-stream-atomic')`) The 52 implementation of `writeStreamAtomic` to use. Used to inject a mock. 53* getuid - (Default: `process.getuid`) A function that returns the current UID. Used to inject a mock. 54