mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
BREAKING: Remove deprecated mkdir, mkdirSync APIs (#4615)
This commit is contained in:
parent
71ac552249
commit
2becae884e
2 changed files with 10 additions and 40 deletions
14
cli/js/lib.deno.ns.d.ts
vendored
14
cli/js/lib.deno.ns.d.ts
vendored
|
@ -1043,13 +1043,6 @@ declare namespace Deno {
|
||||||
* Requires `allow-write` permission. */
|
* Requires `allow-write` permission. */
|
||||||
export function mkdirSync(path: string, options?: MkdirOptions): void;
|
export function mkdirSync(path: string, options?: MkdirOptions): void;
|
||||||
|
|
||||||
/** @deprecated */
|
|
||||||
export function mkdirSync(
|
|
||||||
path: string,
|
|
||||||
recursive?: boolean,
|
|
||||||
mode?: number
|
|
||||||
): void;
|
|
||||||
|
|
||||||
/** Creates a new directory with the specified path.
|
/** Creates a new directory with the specified path.
|
||||||
*
|
*
|
||||||
* await Deno.mkdir("new_dir");
|
* await Deno.mkdir("new_dir");
|
||||||
|
@ -1061,13 +1054,6 @@ declare namespace Deno {
|
||||||
* Requires `allow-write` permission. */
|
* Requires `allow-write` permission. */
|
||||||
export function mkdir(path: string, options?: MkdirOptions): Promise<void>;
|
export function mkdir(path: string, options?: MkdirOptions): Promise<void>;
|
||||||
|
|
||||||
/** @deprecated */
|
|
||||||
export function mkdir(
|
|
||||||
path: string,
|
|
||||||
recursive?: boolean,
|
|
||||||
mode?: number
|
|
||||||
): Promise<void>;
|
|
||||||
|
|
||||||
export interface MakeTempOptions {
|
export interface MakeTempOptions {
|
||||||
/** Directory where the temporary directory should be created (defaults to
|
/** Directory where the temporary directory should be created (defaults to
|
||||||
* the env variable TMPDIR, or the system's default, usually /tmp). */
|
* the env variable TMPDIR, or the system's default, usually /tmp). */
|
||||||
|
|
|
@ -3,25 +3,14 @@ import { sendSync, sendAsync } from "../dispatch_json.ts";
|
||||||
|
|
||||||
type MkdirArgs = { path: string; recursive: boolean; mode?: number };
|
type MkdirArgs = { path: string; recursive: boolean; mode?: number };
|
||||||
|
|
||||||
// TODO(ry) The complexity in argument parsing is to support deprecated forms of
|
function mkdirArgs(path: string, options?: MkdirOptions): MkdirArgs {
|
||||||
// mkdir and mkdirSync.
|
|
||||||
function mkdirArgs(
|
|
||||||
path: string,
|
|
||||||
optionsOrRecursive?: MkdirOptions | boolean,
|
|
||||||
mode?: number
|
|
||||||
): MkdirArgs {
|
|
||||||
const args: MkdirArgs = { path, recursive: false };
|
const args: MkdirArgs = { path, recursive: false };
|
||||||
if (typeof optionsOrRecursive == "boolean") {
|
if (options) {
|
||||||
args.recursive = optionsOrRecursive;
|
if (typeof options.recursive == "boolean") {
|
||||||
if (mode) {
|
args.recursive = options.recursive;
|
||||||
args.mode = mode;
|
|
||||||
}
|
}
|
||||||
} else if (optionsOrRecursive) {
|
if (options.mode) {
|
||||||
if (typeof optionsOrRecursive.recursive == "boolean") {
|
args.mode = options.mode;
|
||||||
args.recursive = optionsOrRecursive.recursive;
|
|
||||||
}
|
|
||||||
if (optionsOrRecursive.mode) {
|
|
||||||
args.mode = optionsOrRecursive.mode;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return args;
|
return args;
|
||||||
|
@ -32,18 +21,13 @@ export interface MkdirOptions {
|
||||||
mode?: number;
|
mode?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mkdirSync(
|
export function mkdirSync(path: string, options?: MkdirOptions): void {
|
||||||
path: string,
|
sendSync("op_mkdir", mkdirArgs(path, options));
|
||||||
optionsOrRecursive?: MkdirOptions | boolean,
|
|
||||||
mode?: number
|
|
||||||
): void {
|
|
||||||
sendSync("op_mkdir", mkdirArgs(path, optionsOrRecursive, mode));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function mkdir(
|
export async function mkdir(
|
||||||
path: string,
|
path: string,
|
||||||
optionsOrRecursive?: MkdirOptions | boolean,
|
options?: MkdirOptions
|
||||||
mode?: number
|
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await sendAsync("op_mkdir", mkdirArgs(path, optionsOrRecursive, mode));
|
await sendAsync("op_mkdir", mkdirArgs(path, options));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue