Rename name/filename arguments to path (#4227)

There's a lot of variation in doc comments and internal code about
whether the first parameter to file system calls is `path` or `name` or
`filename`. For consistency, have made it always be `path`.
This commit is contained in:
dubiousjim 2020-03-06 11:29:23 -05:00 committed by GitHub
parent bb3d9c8280
commit acf0958e94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 111 additions and 114 deletions

View file

@ -26,7 +26,7 @@ export interface WriteFileOptions {
* Requires `allow-write` permission, and `allow-read` if create is `false`.
*/
export function writeFileSync(
filename: string,
path: string,
data: Uint8Array,
options: WriteFileOptions = {}
): void {
@ -34,15 +34,15 @@ export function writeFileSync(
const create = !!options.create;
if (!create) {
// verify that file exists
statSync(filename);
statSync(path);
}
}
const openMode = !!options.append ? "a" : "w";
const file = openSync(filename, openMode);
const file = openSync(path, openMode);
if (options.perm !== undefined && options.perm !== null) {
chmodSync(filename, options.perm);
chmodSync(path, options.perm);
}
writeAllSync(file, data);
@ -59,7 +59,7 @@ export function writeFileSync(
* Requires `allow-write` permission, and `allow-read` if create is `false`.
*/
export async function writeFile(
filename: string,
path: string,
data: Uint8Array,
options: WriteFileOptions = {}
): Promise<void> {
@ -67,15 +67,15 @@ export async function writeFile(
const create = !!options.create;
if (!create) {
// verify that file exists
await stat(filename);
await stat(path);
}
}
const openMode = !!options.append ? "a" : "w";
const file = await open(filename, openMode);
const file = await open(path, openMode);
if (options.perm !== undefined && options.perm !== null) {
await chmod(filename, options.perm);
await chmod(path, options.perm);
}
await writeAll(file, data);