Skip to content

fs.writeFileSync options.mode not work when file already exists #1546

@gemwuu

Description

@gemwuu
echo 1 > a && ls -l a
# -rw-rw-r-- 1 admin admin 2 Aug 24 18:29 a

node -e "fs.writeFileSync('./a', 'echo world', {mode: 0o755})" && ls -l a
# -rw-rw-r-- 1 admin admin 10 Aug 24 18:29 a

./a
# bash: ./a: Permission denied

Even we specify the mode to be 0o755, fs.writeFileSync still doesn't change to file mode which is 0o644.

So the installer which uses fs.writeFileSync L63 won't make esbuild executable.

This is a default behavior on POSIX when trying to write Buffer to an existing file.

PR#1547 shall fix it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions