chown
function is used to change the ownership of a file or directory in a file system. Here's how you can use it from fs-extra
in JavaScript:
index.tsx489 chars20 lines
chown
takes a path to the file/directory, the uid
(user ID) and gid
(group ID) to set, and a callback function that will be called once the operation is complete. In the above example, ownership of the file file.txt
is changed to user with uid 123
and group with gid 123
, while ownership of the directory /path/to/directory
is changed to user with uid 456
and group with gid 456
.
gistlibby LogSnag