MCPcopy Create free account
hub / github.com/Azure/powershell / mv

Function mv

lib/index.js:3406–3427  ·  view source on GitHub ↗

* Moves a path. * * @param source source path * @param dest destination path * @param options optional. See MoveOptions.

(source, dest, options = {})

Source from the content-addressed store, hash-verified

3404 * @param options optional. See MoveOptions.
3405 */
3406function mv(source, dest, options = {}) {
3407 return __awaiter(this, void 0, void 0, function* () {
3408 if (yield ioUtil.exists(dest)) {
3409 let destExists = true;
3410 if (yield ioUtil.isDirectory(dest)) {
3411 // If dest is directory copy src into dest
3412 dest = path.join(dest, path.basename(source));
3413 destExists = yield ioUtil.exists(dest);
3414 }
3415 if (destExists) {
3416 if (options.force == null || options.force) {
3417 yield rmRF(dest);
3418 }
3419 else {
3420 throw new Error('Destination already exists');
3421 }
3422 }
3423 }
3424 yield mkdirP(path.dirname(dest));
3425 yield ioUtil.rename(source, dest);
3426 });
3427}
3428exports.mv = mv;
3429/**
3430 * Remove a path recursively with force

Callers

nothing calls this directly

Calls 2

rmRFFunction · 0.85
mkdirPFunction · 0.85

Tested by

no test coverage detected