Remove unnecessary check

e.g. macOS node shell

    > await fs.rename("/tmp/foo/bar/quxx.txt", "/tmp/foo/a.txt")
    [Error: ENOENT: no such file or directory, rename '/tmp/foo/bar/quxx.txt' -> '/tmp/foo/a.txt']
This commit is contained in:
Manav Rathi 2024-04-14 18:28:10 +05:30
parent eb64a00ed2
commit f5a4830a5a
No known key found for this signature in database

View file

@ -92,9 +92,6 @@ export const readTextFile = async (filePath: string) =>
fs.readFile(filePath, "utf-8"); fs.readFile(filePath, "utf-8");
export const moveFile = async (sourcePath: string, destinationPath: string) => { export const moveFile = async (sourcePath: string, destinationPath: string) => {
if (!existsSync(sourcePath)) {
throw new Error("File does not exist");
}
if (existsSync(destinationPath)) { if (existsSync(destinationPath)) {
throw new Error("Destination file already exists"); throw new Error("Destination file already exists");
} }