diff options
author | Casper Beyer <caspervonb@pm.me> | 2021-02-02 19:05:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-02 12:05:46 +0100 |
commit | 6abf126c2a7a451cded8c6b5e6ddf1b69c84055d (patch) | |
tree | fd94c013a19fcb38954844085821ec1601c20e18 /std/fs/move.ts | |
parent | a2b5d44f1aa9d64f448a2a3cc2001272e2f60b98 (diff) |
chore: remove std directory (#9361)
This removes the std folder from the tree.
Various parts of the tests are pretty tightly dependent
on std (47 direct imports and 75 indirect imports, not
counting the cli tests that use them as fixtures) so I've
added std as a submodule for now.
Diffstat (limited to 'std/fs/move.ts')
-rw-r--r-- | std/fs/move.ts | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/std/fs/move.ts b/std/fs/move.ts deleted file mode 100644 index 2e34e7387..000000000 --- a/std/fs/move.ts +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -import { exists, existsSync } from "./exists.ts"; -import { isSubdir } from "./_util.ts"; - -interface MoveOptions { - overwrite?: boolean; -} - -/** Moves a file or directory */ -export async function move( - src: string, - dest: string, - { overwrite = false }: MoveOptions = {}, -): Promise<void> { - const srcStat = await Deno.stat(src); - - if (srcStat.isDirectory && isSubdir(src, dest)) { - throw new Error( - `Cannot move '${src}' to a subdirectory of itself, '${dest}'.`, - ); - } - - if (overwrite) { - if (await exists(dest)) { - await Deno.remove(dest, { recursive: true }); - } - } else { - if (await exists(dest)) { - throw new Error("dest already exists."); - } - } - - await Deno.rename(src, dest); - - return; -} - -/** Moves a file or directory synchronously */ -export function moveSync( - src: string, - dest: string, - { overwrite = false }: MoveOptions = {}, -): void { - const srcStat = Deno.statSync(src); - - if (srcStat.isDirectory && isSubdir(src, dest)) { - throw new Error( - `Cannot move '${src}' to a subdirectory of itself, '${dest}'.`, - ); - } - - if (overwrite) { - if (existsSync(dest)) { - Deno.removeSync(dest, { recursive: true }); - } - } else { - if (existsSync(dest)) { - throw new Error("dest already exists."); - } - } - - Deno.renameSync(src, dest); -} |