mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 00:29:09 -05:00
Cleanup std/node/fs functions (#5000)
This commit is contained in:
parent
f92bb9cf4d
commit
12c6055855
3 changed files with 7 additions and 16 deletions
|
@ -31,10 +31,8 @@ function getResolvedMode(mode: string | number): number {
|
||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof mode === "string") {
|
if (typeof mode === "string" && !allowedModes.test(mode)) {
|
||||||
if (!allowedModes.test(mode)) {
|
throw new Error("Unrecognized mode: " + mode);
|
||||||
throw new Error("Unrecognized mode: " + mode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return parseInt(mode, 8);
|
return parseInt(mode, 8);
|
||||||
|
|
|
@ -13,9 +13,5 @@ export function copyFile(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function copyFileSync(source: string, destination: string): void {
|
export function copyFileSync(source: string, destination: string): void {
|
||||||
try {
|
Deno.copyFileSync(source, destination);
|
||||||
Deno.copyFileSync(source, destination);
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,12 +35,12 @@ export function mkdir(
|
||||||
);
|
);
|
||||||
Deno.mkdir(path, { recursive, mode })
|
Deno.mkdir(path, { recursive, mode })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (callback && typeof callback == "function") {
|
if (typeof callback === "function") {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
if (callback && typeof callback == "function") {
|
if (typeof callback === "function") {
|
||||||
callback(err);
|
callback(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -62,9 +62,6 @@ export function mkdirSync(path: Path, options?: MkdirOptions): void {
|
||||||
throw new Deno.errors.InvalidData(
|
throw new Deno.errors.InvalidData(
|
||||||
"invalid recursive option , must be a boolean"
|
"invalid recursive option , must be a boolean"
|
||||||
);
|
);
|
||||||
try {
|
|
||||||
Deno.mkdirSync(path, { recursive, mode });
|
Deno.mkdirSync(path, { recursive, mode });
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue