mirror of
https://github.com/ivabus/pantry
synced 2024-11-23 08:55:07 +03:00
chmod before trying to fix-shebangs if necessary
This commit is contained in:
parent
5c7531e66f
commit
e0c0fddcb4
1 changed files with 4 additions and 0 deletions
|
@ -66,5 +66,9 @@ for (const path of Deno.args) {
|
||||||
|
|
||||||
console.verbose({rewrote: path, to: `#!/usr/bin/env ${interpreter}`})
|
console.verbose({rewrote: path, to: `#!/usr/bin/env ${interpreter}`})
|
||||||
|
|
||||||
|
const stat = Deno.lstatSync(path)
|
||||||
|
const needs_chmod = stat.mode && !(stat.mode & 0o200)
|
||||||
|
if (needs_chmod) Deno.chmodSync(path, 0o666)
|
||||||
await Deno.writeFile(path, new TextEncoder().encode(rewrite))
|
await Deno.writeFile(path, new TextEncoder().encode(rewrite))
|
||||||
|
if (needs_chmod) Deno.chmodSync(path, stat.mode!)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue