@types/shelljs
- Version 0.8.15
- Published
- 49.4 kB
- 2 dependencies
- MIT license
Install
npm i @types/shelljs
yarn add @types/shelljs
pnpm add @types/shelljs
Overview
TypeScript definitions for shelljs
Index
Variables
Functions
Interfaces
Type Aliases
Variables
variable cat
const cat: CatFunction;
Returns a string containing the given file, or a concatenated string containing the files if more than one file is given (a new line character is introduced between each file).
Parameter files
Files to use. Wildcard
*
accepted. A string containing the given file, or a concatenated string containing the files if more than one file is given (a new line character is introduced between each file).
variable chmod
const chmod: ChmodFunction;
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.
Parameter 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 recursivelyParameter mode
The access mode. Can be an octal string or a symbolic mode string.
Parameter file
The file to use. Object with shell exit code, stderr and stdout.
variable config
const config: ShellConfig;
The shelljs configuration.
variable cp
const cp: CopyFunction;
Copies files. The wildcard
*
is accepted.Parameter options
Available options: -
-f
: force (default behavior) --n
: no-clobber --u
: only copy if source is newer than dest --r
, -R: recursive --L
: follow symlinks --P
: don't follow symlinksParameter source
The source.
Parameter dest
The destination. Object with shell exit code, stderr and stdout.
variable dirs
const dirs: DirsFunction;
Displays the list of currently remembered directories.
Parameter options
Available options: -
-c
: Clears the directory stack by deleting all of the elements. --N
: Displays the Nth directory (counting from the right of the list printed by dirs when invoked without options), starting with zero. -+N
: Displays the Nth directory (counting from the left of the list printed by dirs when invoked without options), starting with zero. Returns an array of paths in the stack, or a single path if +N or -N was specified.
variable echo
const echo: EchoFunction;
Prints string to stdout, and returns string with additional utility methods like .to().
Parameter options
Available options: -
-e
: interpret backslash escapes (default) --n
: remove trailing newline from outputParameter text
The text to print. Returns the string that was passed as argument.
variable env
const env: NodeJS.ProcessEnv;
Object containing environment variables (both getter and setter). Shortcut to
process.env
.
variable exec
const exec: ExecFunction;
Executes the given command.
Parameter command
The command to execute.
Parameter options
Silence and synchronous options.
Parameter callback
Receives code and output asynchronously. Returns an object containing the return code and output as string, or if
{async: true}
or acallback
was passed, aChildProcess
.
variable find
const find: FindFunction;
Returns array of all files (however deep) in the given paths.
Parameter path
The path(s) to search. An array of all files (however deep) in the given path(s).
variable grep
const grep: GrepFunction;
Reads input string from given files and returns a string containing all lines of the file that match the given
regex_filter
. Wildcard*
accepted.Parameter options
Available options: -
-v
: Inverse the sense of the regex and print the lines not matching the criteria. --l
: Print only filenames of matching filesParameter regex_filter
The regular expression to use.
Parameter files
The files to process. Returns a string containing all lines of the file that match the given
regex_filter
.
variable head
const head: HeadFunction;
Read the start of a file.
variable ln
const ln: LinkFunction;
Links source to dest. Use
-f
to force the link, should dest already exist.Parameter options
Available options: -
-s
: Create a symbolic link, defaults to a hardlink --f
: Force creationParameter source
The source.
Parameter dest
The destination. Object with shell exit code, stderr and stdout.
variable ls
const ls: ListFunction;
Returns array of files in the given path, or in current directory if no path provided.
Parameter options
Available options: -
-R
: recursive --A
: all files (include files beginning with ., except for . and ..) --L
: follow symlinks --d
: list directories themselves, not their contents --l
: list objects representing each file, each with fields containingls -l
output fields. See fs.Stats for more infoParameter paths
Paths to search. An array of files in the given path(s).
variable mkdir
const mkdir: MkdirFunction;
Creates directories.
Parameter options
Available options: -
-p
: full paths, will create intermediate dirs if necessaryParameter dir
The directories to create. Object with shell exit code, stderr and stdout.
variable mv
const mv: MoveFunction;
Moves files. The wildcard
*
is accepted.Parameter options
Available options: -
-f
: force (default behavior) --n
: no-clobberParameter source
The source.
Parameter dest
The destination. Object with shell exit code, stderr and stdout.
variable popd
const popd: PopDirFunction;
When no arguments are given, popd removes the top directory from the stack and performs a
cd
to the new top directory.The elements are numbered from 0 starting at the first directory listed with dirs; i.e.,
popd
is equivalent topopd +0
. Returns an array of paths in the stack.Parameter options
Available options: -
-n
: Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated --q
: Suppresses output to the console.Parameter dir
You can only use -N and +N. Returns an array of paths in the stack.
variable pushd
const pushd: PushDirFunction;
Saves the current directory on the top of the directory stack and then cd to dir. With no arguments,
pushd
exchanges the top two directories.Parameter options
Available options: -
-n
: Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated --q
: Suppresses output to the console.Parameter dir
Makes the current working directory be the top of the stack, and then executes the equivalent of
cd dir
. Returns an array of paths in the stack.
variable rm
const rm: RemoveFunction;
Removes files. The wildcard
*
is accepted.Parameter options
Available options: -
-f
(force), --r
,-R
(recursive)Parameter files
Files to remove. Object with shell exit code, stderr and stdout.
variable sed
const sed: SedFunction;
Reads an input string from file and performs a JavaScript
replace()
on the input using the given search regex and replacement string or function.Parameter options
Available options: -
-i
: Replace contents of 'file' in-place. Note that no backups will be created!Parameter searchRegex
The regular expression to use for search.
Parameter replacement
The replacement.
Parameter files
The files to process. The new string after replacement.
variable ShellString
const ShellString: ShellStringConstructor;
variable sort
const sort: SortFunction;
Return the contents of the files, sorted line-by-line. Sorting multiple files mixes their content (just as unix sort does).
Parameter options
Available options: -
-r
: Reverse the results --n
: Compare according to numerical value
variable tail
const tail: TailFunction;
Read the end of a file.
variable touch
const touch: TouchFunction;
Update the access and modification times of each FILE to the current time. A FILE argument that does not exist is created empty, unless
-c
is supplied
variable uniq
const uniq: UniqFunction;
Filter adjacent matching lines from input.
Parameter options
Available options: -
-i
: Ignore case while comparing --c
: Prefix lines by the number of occurrences --d
: Only print duplicate lines, one for each group of identical lines
Functions
function cd
cd: (dir?: string) => ShellString;
Changes the current working directory dir for the duration of the script. Changes to the home directory if no argument is supplied.
Parameter dir
Directory to change to. Object with shell exit code, stderr and stdout.
function error
error: () => ShellString;
Tests if error occurred in the last command.
Returns null if no error occurred, otherwise returns string explaining the error
function exit
exit: (code?: number) => never;
Exits the current process with the given exit code.
Equivalent to calling
process.exit(code)
.Parameter code
The exit code.
function pwd
pwd: () => ShellString;
Returns the current directory. The current directory.
function set
set: (options: string) => void;
Sets global configuration variables
Parameter options
Available options: -
+/-e
: exit upon error (config.fatal
), -+/-v
: verbose: show all commands (config.verbose
), -+/-f
: disable filename expansion (globbing)
function tempdir
tempdir: () => ShellString;
Searches and returns string containing a writeable, platform-dependent temporary directory. Follows Python's tempfile algorithm.
The temp file path.
function test
test: (option: TestOptions, path: string) => boolean;
Evaluates expression using the available primaries and returns corresponding value.
Parameter option
Valid options: -
-b
: true if path is a block device; --c
: true if path is a character device; --d
: true if path is a directory; --e
: true if path exists; --f
: true if path is a regular file; --L
: true if path is a symbolic link; --p
: true if path is a pipe (FIFO); --S
: true if path is a socketParameter path
The path. See option parameter.
function which
which: (command: string) => ShellString | null;
Searches for command in the system's PATH. On Windows looks for .exe, .cmd, and .bat extensions.
Parameter command
The command to search for. Returns string containing the absolute path to the command or
null
if it couldn't be found.
Interfaces
interface CatFunction
interface CatFunction {}
call signature
(files: string[]): ShellString;
Returns a string containing the given file, or a concatenated string containing the files if more than one file is given (a new line character is introduced between each file).
Parameter files
Files to use. Wildcard
*
accepted. A string containing the given file, or a concatenated string containing the files if more than one file is given (a new line character is introduced between each file).
call signature
(...files: string[]): ShellString;
interface ChmodFunction
interface ChmodFunction {}
call signature
(options: string, mode: string | number, file: string): ShellString;
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.
Parameter 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 recursivelyParameter mode
The access mode. Can be an octal string or a symbolic mode string.
Parameter file
The file to use. Object with shell exit code, stderr and stdout.
call signature
(mode: string | number, file: string): ShellString;
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.
Parameter mode
The access mode. Can be an octal string or a symbolic mode string.
Parameter file
The file to use. Object with shell exit code, stderr and stdout.
interface CopyFunction
interface CopyFunction {}
call signature
(options: string, source: string | string[], dest: string): ShellString;
Copies files. The wildcard
*
is accepted.Parameter options
Available options: -
-f
: force (default behavior) --n
: no-clobber --u
: only copy if source is newer than dest --r
,-R
: recursive --L
: follow symlinks --P
: don't follow symlinksParameter source
The source.
Parameter dest
The destination. Object with shell exit code, stderr and stdout.
call signature
(source: string | string[], dest: string): ShellString;
Copies files. The wildcard
*
is accepted.Parameter source
The source.
Parameter dest
The destination. Object with shell exit code, stderr and stdout.
interface DirsFunction
interface DirsFunction {}
call signature
(options: '-c'): ShellArray;
Clears the directory stack by deleting all of the elements.
Parameter options
Clears the directory stack by deleting all of the elements. Returns an array of paths in the stack, or a single path if +N or -N was specified.
call signature
(options: '+N'): ShellString;
Displays the list of currently remembered directories.
Parameter options
Displays the Nth directory (counting from the left of the list printed by dirs when invoked without options), starting with zero. Returns an array of paths in the stack, or a single path if +N or -N was specified.
call signature
(options: '-N'): ShellString;
Displays the list of currently remembered directories.
Parameter options
Displays the Nth directory (counting from the right of the list printed by dirs when invoked without options), starting with zero. Returns an array of paths in the stack, or a single path if +N or -N was specified.
call signature
(options: string): ShellArray | ShellString;
Displays the list of currently remembered directories.
Parameter options
Available options: -
-c
: Clears the directory stack by deleting all of the elements. --N
: Displays the Nth directory (counting from the right of the list printed by dirs when invoked without options), starting with zero. -+N
: Displays the Nth directory (counting from the left of the list printed by dirs when invoked without options), starting with zero. Returns an array of paths in the stack, or a single path if +N or -N was specified.
interface EchoFunction
interface EchoFunction {}
call signature
(options: string, ...text: string[]): ShellString;
Prints string to stdout, and returns string with additional utility methods like .to().
Parameter options
Available options: -
-e
: interpret backslash escapes (default) --n
: remove trailing newline from outputParameter text
The text to print. Returns the string that was passed as argument.
call signature
(...text: string[]): ShellString;
Prints string to stdout, and returns string with additional utility methods like .to().
Parameter text
The text to print. Returns the string that was passed as argument.
interface ExecFunction
interface ExecFunction {}
call signature
(command: string): ShellString;
Executes the given command synchronously.
Parameter command
The command to execute. Returns an object containing the return code and output as string.
call signature
( command: string, options: ExecOptions & { async?: false | undefined }): ShellString;
Executes the given command synchronously.
Parameter command
The command to execute.
Parameter options
Silence and synchronous options. Returns an object containing the return code and output as string, or if
{async: true}
was passed, aChildProcess
.
call signature
(command: string, options: ExecOptions & { async: true }): child.ChildProcess;
Executes the given command asynchronously.
Parameter command
The command to execute.
Parameter options
Silence and synchronous options. Returns an object containing the return code and output as string, or if
{async: true}
was passed, aChildProcess
.
call signature
(command: string, options: ExecOptions): ShellString | child.ChildProcess;
Executes the given command.
Parameter command
The command to execute.
Parameter options
Silence and synchronous options. Returns an object containing the return code and output as string, or if
{async: true}
was passed, aChildProcess
.
call signature
( command: string, options: ExecOptions, callback: ExecCallback): child.ChildProcess;
Executes the given command synchronously.
Parameter command
The command to execute.
Parameter options
Silence and synchronous options.
Parameter callback
Receives code and output asynchronously.
call signature
(command: string, callback: ExecCallback): child.ChildProcess;
Executes the given command synchronously.
Parameter command
The command to execute.
Parameter callback
Receives code and output asynchronously.
interface ExecOptions
interface ExecOptions extends child.ExecOptions {}
property async
async?: boolean | undefined;
Asynchronous execution.
If a callback is provided, it will be set to
true
, regardless of the passed value.false
property encoding
encoding?: string | undefined;
Character encoding to use.
Affects the values returned by
stdout
andstderr
, and what is written tostdout
andstderr
when not in silent mode"utf8"
property fatal
fatal?: boolean | undefined;
Exit when command return code is non-zero.
false
property silent
silent?: boolean | undefined;
Do not echo program output to the console.
false
interface ExecOutputReturnValue
interface ExecOutputReturnValue {}
interface FindFunction
interface FindFunction {}
call signature
(path: string[]): ShellArray;
Returns array of all files (however deep) in the given paths.
Parameter path
The path(s) to search. An array of all files (however deep) in the given path(s).
call signature
(...path: string[]): ShellArray;
interface GrepFunction
interface GrepFunction {}
call signature
(options: string, regex_filter: string | RegExp, files: string[]): ShellString;
Reads input string from given files and returns a string containing all lines of the file that match the given
regex_filter
. Wildcard*
accepted.Parameter options
Available options: -
-v
: Inverse the sense of the regex and print the lines not matching the criteria. --l
: Print only filenames of matching filesParameter regex_filter
The regular expression to use.
Parameter files
The files to process. Returns a string containing all lines of the file that match the given regex_filter.
call signature
( options: string, regex_filter: string | RegExp, ...files: string[]): ShellString;
call signature
(regex_filter: string | RegExp, files: string[]): ShellString;
Reads input string from given files and returns a string containing all lines of the file that match the given
regex_filter
. Wildcard*
accepted.Parameter regex_filter
The regular expression to use.
Parameter files
The files to process. Returns a string containing all lines of the file that match the given
regex_filter
.
call signature
(regex_filter: string | RegExp, ...files: string[]): ShellString;
interface HeadFunction
interface HeadFunction {}
call signature
(options: HeadOptions, files: string[]): ShellString;
call signature
(options: HeadOptions, ...files: string[]): ShellString;
call signature
(files: string[]): ShellString;
call signature
(...files: string[]): ShellString;
interface HeadOptions
interface HeadOptions {}
property "-n"
'-n': number;
Show the first lines of the files.
interface LinkFunction
interface LinkFunction {}
call signature
(options: string, source: string, dest: string): ShellString;
Links source to dest. Use
-f
to force the link, should dest already exist.Parameter options
Available options: -
-s
: Create a symbolic link, defaults to a hardlink --f
: Force creationParameter source
The source.
Parameter dest
The destination. Object with shell exit code, stderr and stdout.
call signature
(source: string, dest: string): ShellString;
Links source to dest. Use
-f
to force the link, should dest already exist.Parameter source
The source.
Parameter dest
The destination. Object with shell exit code, stderr and stdout.
interface ListFunction
interface ListFunction {}
call signature
(options: string, paths: string[]): ShellArray;
Returns array of files in the given path, or in current directory if no path provided.
Parameter options
Available options: -
-R
: recursive --A
: all files (include files beginning with ., except for . and ..) --L
: follow symlinks --d
: list directories themselves, not their contents --l
: list objects representing each file, each with fields containingls -l
output fields. See fs.Stats for more infoParameter paths
Paths to search. An array of files in the given path(s).
call signature
(options: string, ...paths: string[]): ShellArray;
call signature
(paths: string[]): ShellArray;
Returns array of files in the given path, or in current directory if no path provided.
Parameter paths
Paths to search. An array of files in the given path(s).
call signature
(...paths: string[]): ShellArray;
interface MkdirFunction
interface MkdirFunction {}
call signature
(options: string, dir: string[]): ShellString;
Creates directories.
Parameter options
Available options: -
-p
: full paths, will create intermediate dirs if necessaryParameter dir
The directories to create. Object with shell exit code, stderr and stdout.
call signature
(options: string, ...dir: string[]): ShellString;
call signature
(dir: string[]): ShellString;
Creates directories.
Parameter dir
Directories to create. Object with shell exit code, stderr and stdout.
call signature
(...dir: string[]): ShellString;
interface MoveFunction
interface MoveFunction {}
call signature
(options: string, source: string | string[], dest: string): ShellString;
Moves files. The wildcard
*
is accepted.Parameter options
Available options: -
-f
: force (default behavior) --n
: no-clobberParameter source
The source.
Parameter dest
The destination. Object with shell exit code, stderr and stdout.
call signature
(source: string | string[], dest: string): ShellString;
Moves files. The wildcard
*
is accepted.Parameter source
The source.
Parameter dest
The destination. Object with shell exit code, stderr and stdout.
interface PopDirFunction
interface PopDirFunction {}
call signature
(options: string, dir: '+N'): ShellArray;
When no arguments are given, popd removes the top directory from the stack and performs a
cd
to the new top directory.The elements are numbered from 0 starting at the first directory listed with dirs; i.e.,
popd
is equivalent topopd +0
. Returns an array of paths in the stack.Parameter options
Available options: -
-n
: Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated --q
: Suppresses output to the console.Parameter dir
Removes the Nth directory (counting from the left of the list printed by dirs), starting with zero. Returns an array of paths in the stack.
call signature
(options: string, dir: '-N'): ShellArray;
When no arguments are given, popd removes the top directory from the stack and performs a
cd
to the new top directory.The elements are numbered from 0 starting at the first directory listed with dirs; i.e.,
popd
is equivalent topopd +0
. Returns an array of paths in the stack.Parameter options
Available options: -
-n
: Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated --q
: Suppresses output to the console.Parameter dir
Removes the Nth directory (counting from the right of the list printed by dirs), starting with zero. Returns an array of paths in the stack.
call signature
(options: string, dir: string): ShellArray;
When no arguments are given, popd removes the top directory from the stack and performs a
cd
to the new top directory.The elements are numbered from 0 starting at the first directory listed with dirs; i.e.,
popd
is equivalent topopd +0
. Returns an array of paths in the stack.Parameter options
Available options: -
-n
: Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated --q
: Suppresses output to the console.Parameter dir
You can only use -N and +N. Returns an array of paths in the stack.
call signature
(dir: '+N'): ShellArray;
When no arguments are given, popd removes the top directory from the stack and performs a
cd
to the new top directory.The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0. Returns an array of paths in the stack.
Parameter dir
Removes the Nth directory (counting from the left of the list printed by dirs), starting with zero. Returns an array of paths in the stack.
call signature
(dir: '-N'): ShellArray;
When no arguments are given, popd removes the top directory from the stack and performs a
cd
to the new top directory.The elements are numbered from 0 starting at the first directory listed with dirs; i.e.,
popd
is equivalent topopd +0
. Returns an array of paths in the stack.Parameter dir
Removes the Nth directory (counting from the right of the list printed by dirs), starting with zero. Returns an array of paths in the stack.
call signature
(dir: string): ShellArray;
When no arguments are given, popd removes the top directory from the stack and performs a
cd
to the new top directory.The elements are numbered from 0 starting at the first directory listed with dirs; i.e.,
popd
is equivalent topopd +0
. Returns an array of paths in the stack.Parameter dir
You can only use -N and +N. Returns an array of paths in the stack.
call signature
(): ShellArray;
When no arguments are given, popd removes the top directory from the stack and performs a
cd
to the new top directory.The elements are numbered from 0 starting at the first directory listed with dirs; i.e.,
popd
is equivalent topopd +0
. Returns an array of paths in the stack.Returns an array of paths in the stack.
interface PushDirFunction
interface PushDirFunction {}
call signature
(options: string, dir: '+N'): ShellArray;
Saves the current directory on the top of the directory stack and then cd to dir. With no arguments,
pushd
exchanges the top two directories.Parameter options
Available options: -
-n
: Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated --q
: Suppresses output to the console.Parameter dir
Brings the Nth directory (counting from the left of the list printed by dirs, starting with zero) to the top of the list by rotating the stack. Returns an array of paths in the stack.
call signature
(options: string, dir: '-N'): ShellArray;
Saves the current directory on the top of the directory stack and then cd to dir. With no arguments,
pushd
exchanges the top two directories.Parameter options
Available options: -
-n
: Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated --q
: Suppresses output to the console.Parameter dir
Brings the Nth directory (counting from the right of the list printed by dirs, starting with zero) to the top of the list by rotating the stack. Returns an array of paths in the stack.
call signature
(options: string, dir: string): ShellArray;
Saves the current directory on the top of the directory stack and then cd to dir. With no arguments,
pushd
exchanges the top two directories.Parameter options
Available options: -
-n
: Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated --q
: Suppresses output to the console.Parameter dir
Makes the current working directory be the top of the stack, and then executes the equivalent of
cd dir
. Returns an array of paths in the stack.
call signature
(dir: '+N'): ShellArray;
Saves the current directory on the top of the directory stack and then cd to dir. With no arguments,
pushd
exchanges the top two directories.Parameter dir
Brings the Nth directory (counting from the left of the list printed by dirs, starting with zero) to the top of the list by rotating the stack. Returns an array of paths in the stack.
call signature
(dir: '-N'): ShellArray;
Saves the current directory on the top of the directory stack and then cd to dir. With no arguments,
pushd
exchanges the top two directories.Parameter dir
Brings the Nth directory (counting from the right of the list printed by dirs, starting with zero) to the top of the list by rotating the stack. Returns an array of paths in the stack.
call signature
(dir: string): ShellArray;
Saves the current directory on the top of the directory stack and then cd to dir. With no arguments,
pushd
exchanges the top two directories.Parameter dir
Makes the current working directory be the top of the stack, and then executes the equivalent of cd dir. Returns an array of paths in the stack.
call signature
(): ShellArray;
Saves the current directory on the top of the directory stack and then cd to dir. With no arguments,
pushd
exchanges the top two directories.Returns an array of paths in the stack.
interface RemoveFunction
interface RemoveFunction {}
call signature
(options: string, files: string[]): ShellString;
Removes files. The wildcard
*
is accepted.Parameter options
Available options: -
-f
: force --r
,-R
: recursiveParameter files
Files to remove. Object with shell exit code, stderr and stdout.
call signature
(options: string, ...files: string[]): ShellString;
call signature
(files: string[]): ShellString;
Removes files. The wildcard
*
is accepted.Parameter files
Files to remove. Object with shell exit code, stderr and stdout.
call signature
(...files: string[]): ShellString;
interface SedFunction
interface SedFunction {}
call signature
( options: string, searchRegex: string | RegExp, replacement: string, files: string[]): ShellString;
Reads an input string from file and performs a JavaScript
replace()
on the input using the given search regex and replacement string or function.Parameter options
Available options: -
-i
: Replace contents of 'file' in-place. Note that no backups will be created!Parameter searchRegex
The regular expression to use for search.
Parameter replacement
The replacement.
Parameter files
The files to process. The new string after replacement.
call signature
( options: string, searchRegex: string | RegExp, replacement: string, ...files: string[]): ShellString;
call signature
( searchRegex: string | RegExp, replacement: string, files: string[]): ShellString;
Reads an input string from file and performs a JavaScript
replace()
on the input using the given search regex and replacement string or function.Parameter searchRegex
The regular expression to use for search.
Parameter replacement
The replacement.
Parameter files
The files to process. The new string after replacement.
call signature
( searchRegex: string | RegExp, replacement: string, ...files: string[]): ShellString;
interface ShellConfig
interface ShellConfig {}
property execPath
execPath: string | null;
Absolute path of the Node binary. Default is null (inferred).
property fatal
fatal: boolean;
If true the script will die on errors. Default is false.
property globOptions
globOptions: glob.IOptions;
Passed to glob.sync() instead of the default options ({}).
property silent
silent: boolean;
Suppresses all command output if true, except for echo() calls. Default is false.
property verbose
verbose: boolean;
Will print each executed command to the screen.
false
method reset
reset: () => void;
Reset shell.config to the defaults.
interface ShellReturnValue
interface ShellReturnValue extends ExecOutputReturnValue {}
property cat
cat: CatFunction;
Returns a string containing the given pipeline, or a concatenated string containing the pipelines if more than one input stream is given (a new line character is introduced between each input).
A string containing the given pipeline, or a concatenated string containing the pipelines if more than one input stream is given (a new line character is introduced between each input).
property exec
exec: ExecFunction;
Executes the given command.
Parameter command
The command to execute.
Parameter options
Silence and synchronous options.
Parameter callback
Receives code and output asynchronously. Returns an object containing the return code and output as string, or if
{async: true}
or acallback
was passed, aChildProcess
.
property grep
grep: GrepFunction;
Reads input string from given files and returns a string containing all lines of the file that match the given
regex_filter
. Wildcard*
accepted.Parameter options
Available options: -
-v
: Inverse the sense of the regex and print the lines not matching the criteria. --l
: Print only filenames of matching filesParameter regex_filter
The regular expression to use. Returns a string containing all lines of the file that match the given
regex_filter
.
property head
head: HeadFunction;
Read the start of a pipeline input.
property sed
sed: SedFunction;
Reads an input string from pipeline and performs a JavaScript
replace()
on the input using the given search regex and replacement string or function.Parameter options
Available options: -
-i
: Replace contents of 'file' in-place. Note that no backups will be created!Parameter searchRegex
The regular expression to use for search.
Parameter replacement
The replacement. The new string after replacement.
property sort
sort: SortFunction;
Return the contents of the pipeline, sorted line-by-line.
Parameter options
Available options: -
-r
: Reverse the results --n
: Compare according to numerical value
property tail
tail: TailFunction;
Read the end of a pipeline input.
property uniq
uniq: UniqFunction;
Filter adjacent matching lines from input.
Parameter options
Available options: -
-i
: Ignore case while comparing --c
: Prefix lines by the number of occurrences --d
: Only print duplicate lines, one for each group of identical lines
method to
to: (file: string) => void;
Analogous to the redirection operator
>
in Unix, but works with JavaScript strings (such as those returned bycat
,grep
, etc).Like Unix redirections,
to()
will overwrite any existing file!Parameter file
The file to use.
method toEnd
toEnd: (file: string) => void;
Analogous to the redirect-and-append operator
>>
in Unix, but works with JavaScript strings (such as those returned bycat
,grep
, etc).Parameter file
The file to append to.
interface ShellStringConstructor
interface ShellStringConstructor {}
construct signature
new (value: string): ShellString;
Wraps a string (or array) value. This has all the string (or array) methods, but also exposes extra methods:
.to()
,.toEnd()
, and all the pipe-able methods (ex..cat()
,.grep()
, etc.).This can be easily converted into a string by calling
.toString()
.This type also exposes the corresponding command's stdout, stderr, and return status code via the
.stdout
(string),.stderr
(string), and.code
(number) properties respectively.Construct signature allows for:
var foo = new ShellString('hello world');
as per example in shelljs docs: https://github.com/shelljs/shelljs#shellstringstr
Parameter value
The string value to wrap. A string-like object with special methods.
construct signature
new (value: string[]): ShellArray;
call signature
(value: string): ShellString;
Wraps a string (or array) value. This has all the string (or array) methods, but also exposes extra methods:
.to()
,.toEnd()
, and all the pipe-able methods (ex..cat()
,.grep()
, etc.).This can be easily converted into a string by calling
.toString()
.This type also exposes the corresponding command's stdout, stderr, and return status code via the
.stdout
(string),.stderr
(string), and.code
(number) properties respectively.Parameter value
The string value to wrap. A string-like object with special methods.
call signature
(value: string[]): ShellArray;
interface SortFunction
interface SortFunction {}
call signature
(options: string, files: string[]): ShellString;
Return the contents of the files, sorted line-by-line. Sorting multiple files mixes their content (just as unix sort does).
Parameter options
Available options: -
-r
: Reverse the results --n
: Compare according to numerical value
call signature
(options: string, ...files: string[]): ShellString;
call signature
(files: string[]): ShellString;
Return the contents of the files, sorted line-by-line. Sorting multiple files mixes their content (just as unix sort does).
call signature
(...files: string[]): ShellString;
interface TailFunction
interface TailFunction {}
call signature
(options: TailOptions, files: string[]): ShellString;
call signature
(options: TailOptions, ...files: string[]): ShellString;
call signature
(files: string[]): ShellString;
call signature
(...files: string[]): ShellString;
interface TailOptions
interface TailOptions {}
property "-n"
'-n': number;
Show the last lines of files.
interface TouchFunction
interface TouchFunction {}
call signature
(options: TouchOptionsLiteral | TouchOptionsArray, files: string[]): ShellString;
call signature
( options: TouchOptionsLiteral | TouchOptionsArray, ...files: string[]): ShellString;
call signature
(files: string[]): ShellString;
call signature
(...files: string[]): ShellString;
interface TouchOptionsArray
interface TouchOptionsArray {}
interface UniqFunction
interface UniqFunction {}
call signature
(options: string, input: string, output?: string): ShellString;
Filter adjacent matching lines from input.
Parameter options
Available options: -
-i
: Ignore case while comparing --c
: Prefix lines by the number of occurrences --d
: Only print duplicate lines, one for each group of identical lines
call signature
(input: string, output?: string): ShellString;
Filter adjacent matching lines from input.
Type Aliases
type ExecCallback
type ExecCallback = ( /** The process exit code. */ code: number, /** The process standard output. */ stdout: string, /** The process standard error output. */ stderr: string) => any;
type ShellArray
type ShellArray = string[] & ShellReturnValue;
type ShellString
type ShellString = string & ShellReturnValue;
type TestOptions
type TestOptions = '-b' | '-c' | '-d' | '-e' | '-f' | '-L' | '-p' | '-S';
type TouchOptionsLiteral
type TouchOptionsLiteral = '-a' | '-c' | '-m' | '-d' | '-r';
Package Files (1)
Dependencies (2)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/shelljs
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/shelljs)
- HTML<a href="https://www.jsdocs.io/package/@types/shelljs"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 5476 ms. - Missing or incorrect documentation? Open an issue for this package.