Set the permission bits for the specified file.
Provides the same functionality as the unix binary of the same name.
const chmod: Chmod;The interface for the global function chmod, which has two call signatures.
interface Chmod {
(permissions: number | string, path: string | Path): void;
<Operation extends Chmod.Operation>(
operation: Operation,
permissions: Partial<Record<Chmod.Who, Chmod.Permission>>,
path: string | Path,
): void;
}Set the permission bits for the specified file.
Provides the same functionality as the unix binary of the same name.
@parampermissions — The permission bits to set. This can be a number, or a string containing an octal number.@parampath — The path to the file.
(permissions: number | string, path: string | Path): void;Apply a change to the permission bits for the specified file.
Provides the same functionality as the unix binary of the same name.
@paramoperation — What to do to the bits; can be "add", "set", or "remove".@parampermissions — An object describing the changes (see below).@parampath — The path to the file.
Each of the permissions object's own property keys must be one of these
strings:
"user""group""others""all"(meaning "user", "group", and "others")"u"(alias for "user")"g"(alias for "group")"o"(alias for "others")"a"(alias for "all")"ug"("user" plus "group")"go"("group" plus "others")"uo"("user" plus "others")
and their values must be one of these strings:
"read"(permission to read the contents of the file)"write"(permission to write to the file's contents)"execute"(permission to run the file as an executable)"readwrite"(both "read" and "write")"none"(no permissions)"full"("read", "write", and "execute")"r"(alias for "read")"w"(alias for "write")"x"(alias for "execute")"rw"(alias for "readwrite")"rx"("read" and "execute")"wx"("write" and "execute")"rwx"(alias for "full")
Some example objects:
{ user: "readwrite", group: "read", others: "none" }
{ ug: "rw", o: "w" }
{ all: "full" }<Operation extends Chmod.Operation>(operation: Operation, permissions: Partial<Record<Chmod.Who, Chmod.Permission>>, path: string | Path): void;declare namespace Chmod {
export type Who =
| "user"
| "group"
| "others"
| "all"
| "u"
| "g"
| "o"
| "a"
| "ug"
| "go"
| "uo";
export type Operation = "add" | "set" | "remove";
export type Permission =
| "read"
| "write"
| "execute"
| "readwrite"
| "none"
| "full"
| "r"
| "w"
| "x"
| "rw"
| "rx"
| "wx"
| "rwx";
}A string representing who a permission applies to.
type Who =
| "user"
| "group"
| "others"
| "all"
| "u"
| "g"
| "o"
| "a"
| "ug"
| "go"
| "uo";A string representing how the permissions should be changed.
type Operation = "add" | "set" | "remove";A string representing the access level for the given permission.
type Permission =
| "read"
| "write"
| "execute"
| "readwrite"
| "none"
| "full"
| "r"
| "w"
| "x"
| "rw"
| "rx"
| "wx"
| "rwx";