Here's an example of how to use fchmodsync
function from fs-extra
package to change file permissions synchronously in Node.js:
129 chars5 lines
In this example, the fchmodSync
function is called with two arguments: the path to the file whose permissions need to be changed, and the new permissions value in octal format. 0o440
sets file permissions to read-only for owner and group, and no permissions for others.
Note that this function works synchronously and may block the event loop if it takes a long time to complete. For asynchronous version, you can use fchmod
function instead.
gistlibby LogSnag