fs-chmod
A drop-in replacement of fs.chmod
with +x
support.
- supports finer-grained symbolic modes, such as
+x
,ug+rw
, and etc. - supports mode object to make the mode better described.
Install
$ npm i fs-chmod
Usage
const chmod chmodSync parse } = chmodSync
chmod(path, mode): Promise
chmod(path, mode, callback): void
chmodSync(path, mode): void
- path
string | Buffer | URL
the same as vanillafs.chmod
- mode
integer | Mode | string
- callback
Function(error?)
Changes the permissions of a file.
parse(str): Mode
- str
string
Symbolic notation string of file system permissions
Parses the symbolic notation string, such as +x
, ug+rwx
into an object of the interface Mode
(see below)
const mode = console // trueconsole // falseconsole // undefined
mode
integer
mode The same as the the second parameter of vanilla fs.chmod
.
PAY ATTENTION that mode
should be an octal number.
// ✅ Correct~ // ❌ WRONG!
object<Mode>
mode
For details, see symbolic modes
# bash chmod ug+rst /path/to/file
is equivalent to
// or
string
mode [references][operator][modes]
- Supported references:
u
,g
,o
,a
- Supported operators:
+
,=
,-
- Supported modes:
r
,w
,x
s
: setuid/setgidt
: sticky