diff options
author | dubiousjim <dubiousjim@gmail.com> | 2020-03-20 16:03:04 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-20 16:03:04 -0400 |
commit | 77a44163fb22139a8269eb216014640aaf7a7fa8 (patch) | |
tree | 30d7973a4bfbfb36fab385b039ef60574178af2c /cli/js/write_file.ts | |
parent | b22f48970fc18c4e5fd72df15ac798477fbe49cb (diff) |
chmod should throw on Windows (#4446)
Diffstat (limited to 'cli/js/write_file.ts')
-rw-r--r-- | cli/js/write_file.ts | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/cli/js/write_file.ts b/cli/js/write_file.ts index 5227bfece..ed64141d2 100644 --- a/cli/js/write_file.ts +++ b/cli/js/write_file.ts @@ -3,6 +3,7 @@ import { stat, statSync } from "./ops/fs/stat.ts"; import { open, openSync } from "./files.ts"; import { chmod, chmodSync } from "./ops/fs/chmod.ts"; import { writeAll, writeAllSync } from "./buffer.ts"; +import { build } from "./build.ts"; export interface WriteFileOptions { append?: boolean; @@ -26,7 +27,11 @@ export function writeFileSync( const openMode = !!options.append ? "a" : "w"; const file = openSync(path, openMode); - if (options.mode !== undefined && options.mode !== null) { + if ( + options.mode !== undefined && + options.mode !== null && + build.os !== "win" + ) { chmodSync(path, options.mode); } @@ -50,7 +55,11 @@ export async function writeFile( const openMode = !!options.append ? "a" : "w"; const file = await open(path, openMode); - if (options.mode !== undefined && options.mode !== null) { + if ( + options.mode !== undefined && + options.mode !== null && + build.os !== "win" + ) { await chmod(path, options.mode); } |