Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions types/shelljs/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Project: http://shelljs.org
// Definitions by: Niklas Mollenhauer <https://github.com/nikeee>
// Vojtech Jasny <https://github.com/voy>
// George Kalpakas <https://github.com/gkalpak>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/// <reference types="node"/>
Expand Down Expand Up @@ -381,6 +382,16 @@ export type ShellArray = string[] & ShellReturnValue;
*/
export function chmod(octalMode: number, file: string): void;

/**
* Alters the permissions of a file or directory by either specifying the absolute permissions in octal form or expressing the changes in symbols. This command tries to mimic the POSIX behavior as much as possible. Notable exceptions:
* - In symbolic modes, 'a-r' and '-r' are identical. No consideration is given to the umask.
* - There is no "quiet" option since default behavior is to run silent.
* @param options Available options: -v (output a diagnostic for every file processed), -c (like -v but report only when a change is made), -R (change files and directories recursively)
* @param octalMode The access mode. Octal.
* @param file The file to use.
*/
export function chmod(options: string, octalMode: number, file: string): void;

/**
* Alters the permissions of a file or directory by either specifying the absolute permissions in octal form or expressing the changes in symbols. This command tries to mimic the POSIX behavior as much as possible. Notable exceptions:
* - In symbolic modes, 'a-r' and '-r' are identical. No consideration is given to the umask.
Expand All @@ -390,6 +401,16 @@ export function chmod(octalMode: number, file: string): void;
*/
export function chmod(mode: string, file: string): void;

/**
* Alters the permissions of a file or directory by either specifying the absolute permissions in octal form or expressing the changes in symbols. This command tries to mimic the POSIX behavior as much as possible. Notable exceptions:
* - In symbolic modes, 'a-r' and '-r' are identical. No consideration is given to the umask.
* - There is no "quiet" option since default behavior is to run silent.
* @param options Available options: -v (output a diagnostic for every file processed), -c (like -v but report only when a change is made), -R (change files and directories recursively)
* @param mode The access mode. Can be an octal string or a symbolic mode string.
* @param file The file to use.
*/
export function chmod(options: string, mode: string, file: string): void;

// Non-Unix commands

/**
Expand Down
2 changes: 2 additions & 0 deletions types/shelljs/shelljs-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ shell.set('-f');
shell.chmod(755, "/Users/brandon");
shell.chmod("755", "/Users/brandon"); // same as above
shell.chmod("u+x", "/Users/brandon");
shell.chmod("-cR", 755, "/Users/brandon");
shell.chmod("-Rv", "u+x", "/Users/brandon");

shell.exit(0);

Expand Down