1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-25 00:29:09 -05:00

Rename Option -> Options (#4226)

* Rename MkdirOption interface to MkdirOptions

It was hard to remember which Options interfaces were spelled in the
singular and which in the plural (and anyway this one contained two
options).

Also added MkdirOptions to cli/js/deno.ts. All the analogous interfaces
were exported there.

* Rename RemoveOption interface to RemoveOptions

This was the last remaining Option interface spelled in the singular.
Easier to remember if they're all Option**s**; plus we may want to add extra
options here later.
This commit is contained in:
dubiousjim 2020-03-02 15:24:42 -05:00 committed by GitHub
parent ff5bba3be8
commit a3c3a56ff7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 16 deletions

View file

@ -73,7 +73,7 @@ export {
MakeTempOptions MakeTempOptions
} from "./make_temp.ts"; } from "./make_temp.ts";
export { metrics, Metrics } from "./metrics.ts"; export { metrics, Metrics } from "./metrics.ts";
export { mkdirSync, mkdir } from "./mkdir.ts"; export { mkdirSync, mkdir, MkdirOptions } from "./mkdir.ts";
export { export {
Addr, Addr,
connect, connect,
@ -115,7 +115,7 @@ export { readDirSync, readDir } from "./read_dir.ts";
export { readFileSync, readFile } from "./read_file.ts"; export { readFileSync, readFile } from "./read_file.ts";
export { readlinkSync, readlink } from "./read_link.ts"; export { readlinkSync, readlink } from "./read_link.ts";
export { realpathSync, realpath } from "./realpath.ts"; export { realpathSync, realpath } from "./realpath.ts";
export { removeSync, remove, RemoveOption } from "./remove.ts"; export { removeSync, remove, RemoveOptions } from "./remove.ts";
export { renameSync, rename } from "./rename.ts"; export { renameSync, rename } from "./rename.ts";
export { resources } from "./resources.ts"; export { resources } from "./resources.ts";
export { signal, signals, SignalStream } from "./signals.ts"; export { signal, signals, SignalStream } from "./signals.ts";

View file

@ -721,7 +721,7 @@ declare namespace Deno {
// @url js/mkdir.d.ts // @url js/mkdir.d.ts
export interface MkdirOption { export interface MkdirOptions {
/** Defaults to `false`. If set to `true`, means that any intermediate /** Defaults to `false`. If set to `true`, means that any intermediate
* directories will also be created (as with the shell command `mkdir -p`). * directories will also be created (as with the shell command `mkdir -p`).
* Intermediate directories are created with the same permissions. * Intermediate directories are created with the same permissions.
@ -740,7 +740,7 @@ declare namespace Deno {
* Deno.mkdirSync("nested/directories", { recursive: true }); * Deno.mkdirSync("nested/directories", { recursive: true });
* *
* Requires `allow-write` permission. */ * Requires `allow-write` permission. */
export function mkdirSync(path: string, options?: MkdirOption): void; export function mkdirSync(path: string, options?: MkdirOptions): void;
/** @deprecated */ /** @deprecated */
export function mkdirSync( export function mkdirSync(
@ -755,7 +755,7 @@ declare namespace Deno {
* await Deno.mkdir("nested/directories", { recursive: true }); * await Deno.mkdir("nested/directories", { recursive: true });
* *
* Requires `allow-write` permission. */ * Requires `allow-write` permission. */
export function mkdir(path: string, options?: MkdirOption): Promise<void>; export function mkdir(path: string, options?: MkdirOptions): Promise<void>;
/** @deprecated */ /** @deprecated */
export function mkdir( export function mkdir(
@ -920,8 +920,7 @@ declare namespace Deno {
// @url js/remove.d.ts // @url js/remove.d.ts
/** UNSTABLE: rename to RemoveOptions */ export interface RemoveOptions {
export interface RemoveOption {
/** Defaults to `false`. If set to `true`, path will be removed even if /** Defaults to `false`. If set to `true`, path will be removed even if
* it's a non-empty directory. */ * it's a non-empty directory. */
recursive?: boolean; recursive?: boolean;
@ -934,7 +933,7 @@ declare namespace Deno {
* Deno.removeSync("/path/to/dir/or/file", { recursive: false }); * Deno.removeSync("/path/to/dir/or/file", { recursive: false });
* *
* Requires `allow-write` permission. */ * Requires `allow-write` permission. */
export function removeSync(path: string, options?: RemoveOption): void; export function removeSync(path: string, options?: RemoveOptions): void;
/** Removes the named file or directory. Throws error if permission denied, /** Removes the named file or directory. Throws error if permission denied,
* path not found, or path is a non-empty directory and the `recursive` * path not found, or path is a non-empty directory and the `recursive`
@ -943,7 +942,7 @@ declare namespace Deno {
* await Deno.remove("/path/to/dir/or/file", { recursive: false }); * await Deno.remove("/path/to/dir/or/file", { recursive: false });
* *
* Requires `allow-write` permission. */ * Requires `allow-write` permission. */
export function remove(path: string, options?: RemoveOption): Promise<void>; export function remove(path: string, options?: RemoveOptions): Promise<void>;
// @url js/rename.d.ts // @url js/rename.d.ts

View file

@ -5,7 +5,7 @@ import { sendSync, sendAsync } from "./dispatch_json.ts";
// mkdir and mkdirSync. // mkdir and mkdirSync.
function mkdirArgs( function mkdirArgs(
path: string, path: string,
optionsOrRecursive?: MkdirOption | boolean, optionsOrRecursive?: MkdirOptions | boolean,
mode?: number mode?: number
): { path: string; recursive: boolean; mode: number } { ): { path: string; recursive: boolean; mode: number } {
const args = { path, recursive: false, mode: 0o777 }; const args = { path, recursive: false, mode: 0o777 };
@ -25,7 +25,7 @@ function mkdirArgs(
return args; return args;
} }
export interface MkdirOption { export interface MkdirOptions {
/** Defaults to `false`. If set to `true`, means that any intermediate /** Defaults to `false`. If set to `true`, means that any intermediate
* directories will also be created (as with the shell command `mkdir -p`). * directories will also be created (as with the shell command `mkdir -p`).
* Intermediate directories are created with the same permissions. * Intermediate directories are created with the same permissions.
@ -46,7 +46,7 @@ export interface MkdirOption {
* Requires `allow-write` permission. */ * Requires `allow-write` permission. */
export function mkdirSync( export function mkdirSync(
path: string, path: string,
optionsOrRecursive?: MkdirOption | boolean, optionsOrRecursive?: MkdirOptions | boolean,
mode?: number mode?: number
): void { ): void {
sendSync("op_mkdir", mkdirArgs(path, optionsOrRecursive, mode)); sendSync("op_mkdir", mkdirArgs(path, optionsOrRecursive, mode));
@ -60,7 +60,7 @@ export function mkdirSync(
* Requires `allow-write` permission. */ * Requires `allow-write` permission. */
export async function mkdir( export async function mkdir(
path: string, path: string,
optionsOrRecursive?: MkdirOption | boolean, optionsOrRecursive?: MkdirOptions | boolean,
mode?: number mode?: number
): Promise<void> { ): Promise<void> {
await sendAsync("op_mkdir", mkdirArgs(path, optionsOrRecursive, mode)); await sendAsync("op_mkdir", mkdirArgs(path, optionsOrRecursive, mode));

View file

@ -1,7 +1,7 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "./dispatch_json.ts"; import { sendSync, sendAsync } from "./dispatch_json.ts";
export interface RemoveOption { export interface RemoveOptions {
/** Defaults to `false`. If set to `true`, path will be removed even if /** Defaults to `false`. If set to `true`, path will be removed even if
* it's a non-empty directory. */ * it's a non-empty directory. */
recursive?: boolean; recursive?: boolean;
@ -14,7 +14,7 @@ export interface RemoveOption {
* Deno.removeSync("/path/to/dir/or/file", { recursive: false }); * Deno.removeSync("/path/to/dir/or/file", { recursive: false });
* *
* Requires `allow-write` permission. */ * Requires `allow-write` permission. */
export function removeSync(path: string, options: RemoveOption = {}): void { export function removeSync(path: string, options: RemoveOptions = {}): void {
sendSync("op_remove", { path, recursive: !!options.recursive }); sendSync("op_remove", { path, recursive: !!options.recursive });
} }
@ -27,7 +27,7 @@ export function removeSync(path: string, options: RemoveOption = {}): void {
* Requires `allow-write` permission. */ * Requires `allow-write` permission. */
export async function remove( export async function remove(
path: string, path: string,
options: RemoveOption = {} options: RemoveOptions = {}
): Promise<void> { ): Promise<void> {
await sendAsync("op_remove", { path, recursive: !!options.recursive }); await sendAsync("op_remove", { path, recursive: !!options.recursive });
} }