Rush StackShopBlogEvents
Skip to main content

Home > @rushstack/node-core-library > Executable > spawnSync

Executable.spawnSync() method

Synchronously create a child process and optionally capture its output.

Signature:

static spawnSync(filename: string, args: string[], options?: IExecutableSpawnSyncOptions): child_process.SpawnSyncReturns<string>;

Parameters

ParameterTypeDescription
filenamestringThe name of the executable file. This string must not contain any command-line arguments. If the name contains any path delimiters, then the shell's default PATH will not be searched.
argsstring[]The command-line arguments to be passed to the process.
optionsIExecutableSpawnSyncOptions(Optional) Additional options

Returns:

child_process.SpawnSyncReturns<string>

the same data type as returned by the NodeJS child_process.spawnSync() API

Remarks

This function is similar to child_process.spawnSync(). The main differences are:

  • It does not invoke the OS shell unless the executable file is a shell script. - Command-line arguments containing special characters are more accurately passed through to the child process. - If the filename is missing a path, then the shell's default PATH will be searched. - If the filename is missing a file extension, then Windows default file extensions will be searched.