chmodRecursively() function
Recursively changes file permissions within a folder tree.
Signature
export declare function chmodRecursively({ inputPath, readOnly, log, }: {
inputPath: string;
readOnly: boolean;
log: Logger;
}): Promise<void>;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
{ inputPath, readOnly, log, } |
{ inputPath: string; readOnly: boolean; log: Logger; } |
Returns
Promise<void>
A promise that resolves when all permissions have been updated.
Remarks
This function modifies file system permissions recursively, handling both files and directories with special logic to avoid permission conflicts.
Processing strategy:
- Symbolic links: Ignored because links permissions cannot be reliably changed across platforms.
- Read-only mode: Process folder contents first (recursively), then set the folder itself to read-only. This prevents permission denied errors when trying to access a read-only folder's contents.
- Read-write mode: Set folder to read-write first, then process contents recursively. This ensures the folder is writable before attempting to modify nested items.
Permission modes applied:
- Read-only: Removes all write bits (user, group, other) using bitwise AND with negated
S\_IWUSR\|S\_IWGRP\|S\_IWOTH. - Read-write: Adds only user write bit using bitwise OR with
S\_IWUSR, preserving existing group and other permissions.
The function validates the result after each chmod operation and logs warnings if the expected permission state is not achieved, which can occur on filesystems with non-standard permission handling.
Generated via tsdoc2docusaurus 1.3.0-pre by API Extractor/Documenter 7.55.2.