mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
Rename perm to mode (#4276)
There's a lot of variation in doc comments and internal code about whether chmod/0o777-style permissions are called `mode` or `perm`. (For example, mkdir and writeFile choose differently.) Had proposed earlier to go consistently with `perm`, but on balance devs prefer to go with `mode`.
This commit is contained in:
parent
8d1ba3552f
commit
0dd131d4a5
12 changed files with 52 additions and 51 deletions
|
@ -13,7 +13,7 @@ export interface WriteFileOptions {
|
|||
* exist at the specified path (defaults to `true`). */
|
||||
create?: boolean;
|
||||
/** Permissions always applied to file. */
|
||||
perm?: number;
|
||||
mode?: number;
|
||||
}
|
||||
|
||||
/** Synchronously write data to the given path, by default creating a new
|
||||
|
@ -41,8 +41,8 @@ export function writeFileSync(
|
|||
const openMode = !!options.append ? "a" : "w";
|
||||
const file = openSync(path, openMode);
|
||||
|
||||
if (options.perm !== undefined && options.perm !== null) {
|
||||
chmodSync(path, options.perm);
|
||||
if (options.mode !== undefined && options.mode !== null) {
|
||||
chmodSync(path, options.mode);
|
||||
}
|
||||
|
||||
writeAllSync(file, data);
|
||||
|
@ -74,8 +74,8 @@ export async function writeFile(
|
|||
const openMode = !!options.append ? "a" : "w";
|
||||
const file = await open(path, openMode);
|
||||
|
||||
if (options.perm !== undefined && options.perm !== null) {
|
||||
await chmod(path, options.perm);
|
||||
if (options.mode !== undefined && options.mode !== null) {
|
||||
await chmod(path, options.mode);
|
||||
}
|
||||
|
||||
await writeAll(file, data);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue