Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING CHANGE: Remove deprecated mkdir, mkdirSync APIs #4615

Merged
merged 1 commit into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions cli/js/lib.deno.ns.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1043,13 +1043,6 @@ declare namespace Deno {
* Requires `allow-write` permission. */
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.
*
* await Deno.mkdir("new_dir");
Expand All @@ -1061,13 +1054,6 @@ declare namespace Deno {
* Requires `allow-write` permission. */
export function mkdir(path: string, options?: MkdirOptions): Promise<void>;

/** @deprecated */
export function mkdir(
path: string,
recursive?: boolean,
mode?: number
): Promise<void>;

export interface MakeTempOptions {
/** Directory where the temporary directory should be created (defaults to
* the env variable TMPDIR, or the system's default, usually /tmp). */
Expand Down
36 changes: 10 additions & 26 deletions cli/js/ops/fs/mkdir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,14 @@ import { sendSync, sendAsync } from "../dispatch_json.ts";

type MkdirArgs = { path: string; recursive: boolean; mode?: number };

// TODO(ry) The complexity in argument parsing is to support deprecated forms of
// mkdir and mkdirSync.
function mkdirArgs(
path: string,
optionsOrRecursive?: MkdirOptions | boolean,
mode?: number
): MkdirArgs {
function mkdirArgs(path: string, options?: MkdirOptions): MkdirArgs {
const args: MkdirArgs = { path, recursive: false };
if (typeof optionsOrRecursive == "boolean") {
args.recursive = optionsOrRecursive;
if (mode) {
args.mode = mode;
}
} else if (optionsOrRecursive) {
if (typeof optionsOrRecursive.recursive == "boolean") {
args.recursive = optionsOrRecursive.recursive;
if (options) {
if (typeof options.recursive == "boolean") {
args.recursive = options.recursive;
}
if (optionsOrRecursive.mode) {
args.mode = optionsOrRecursive.mode;
if (options.mode) {
args.mode = options.mode;
}
}
return args;
Expand All @@ -32,18 +21,13 @@ export interface MkdirOptions {
mode?: number;
}

export function mkdirSync(
path: string,
optionsOrRecursive?: MkdirOptions | boolean,
mode?: number
): void {
sendSync("op_mkdir", mkdirArgs(path, optionsOrRecursive, mode));
export function mkdirSync(path: string, options?: MkdirOptions): void {
sendSync("op_mkdir", mkdirArgs(path, options));
}

export async function mkdir(
path: string,
optionsOrRecursive?: MkdirOptions | boolean,
mode?: number
options?: MkdirOptions
): Promise<void> {
await sendAsync("op_mkdir", mkdirArgs(path, optionsOrRecursive, mode));
await sendAsync("op_mkdir", mkdirArgs(path, options));
}