
Security News
PolinRider: North Korea-Linked Supply Chain Campaign Expands Across Open Source Ecosystems
PolinRider expands across npm, Packagist, Go modules, and Chrome extensions, using hidden loaders to target developer environments.
@zoroaster/fork
Advanced tools
@zoroaster/fork is used in Zoroaster to test forks.
yarn add -E @zoroaster/fork
async fork(forkConfig: string|ForkConfig, input: string, props?: *, contexts?: Context[]): { stdout, stderr, code }
The package is available by importing its default function:
import fork from '@zoroaster/fork'
async fork(forkConfig: string|ForkConfig,input: string,props?: *,contexts?: Context[],): { stdout, stderr, code }This method will fork a process, and pass the inputs when stdin expects an input. Because includeAnswers is set to true by default, the answers will be included in the resulting stdout and stderr properties.
import('child_process').ForkOptions ForkOptions
ForkConfig: Parameters for forking.
| Name | Type | Description | Default |
|---|---|---|---|
| module* | string | The path to the module to fork. | - |
| getArgs | (args: string[], ...contexts?: Context[]) => string[]|Promise.<string[]> | The function to get arguments to pass the fork based on the parsed mask input and contexts. | - |
| getOptions | (...contexts?: Context[]) => ForkOptions | The function to get options for the fork, such as ENV and cwd, based on contexts. | - |
| options | ForkOptions | Options for the forked processed, such as ENV and cwd. | - |
| inputs | [RegExp, string][] | Inputs to push to stdin when stdout writes data. The inputs are kept on stack, and taken off the stack when the RegExp matches the written data. | - |
| stderrInputs | [RegExp, string][] | Inputs to push to stdin when stderr writes data (similar to inputs). | - |
| log | boolean|{stderr: Writable, stdout: Writable} | Whether to pipe data from stdout, stderr to the process's streams. If an object is passed, the output will be piped to streams specified as its stdout and stderr properties. | false |
| includeAnswers | boolean | Whether to add the answers to the stderr and stdout output. | true |
For example, to test the fork with the next code:
const [,, ...args] = process.argv
console.log(args)
console.error(process.env.EXAMPLE)
process.exit(5)
The ContextTesting/Fork can be used:
/* yarn example/ */
import fork from '@zoroaster/fork'
(async () => {
const res = await fork({
contexts: ['CONTEXT'],
forkConfig: {
module: 'example/fork',
getArgs(inputs) {
return [...inputs, this.prop1]
},
getOptions(CONTEXT) {
return {
env: {
EXAMPLE: `${CONTEXT} - ${this.input}`,
},
}
},
},
input: 'hello world',
props: {
prop1: '999',
},
})
console.log(res)
})()
{ code: 5,
stdout: '[ \'hello\', \'world\', \'999\' ]\n',
stderr: 'CONTEXT - hello world\n' }
(c) Context Testing 2019
FAQs
Test forks.
The npm package @zoroaster/fork receives a total of 41 weekly downloads. As such, @zoroaster/fork popularity was classified as not popular.
We found that @zoroaster/fork demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
PolinRider expands across npm, Packagist, Go modules, and Chrome extensions, using hidden loaders to target developer environments.

Security News
Open source attacks are accelerating as AI coding agents pull in dependencies faster, with less human review.

Research
/Security News
Malicious Chrome and Firefox extensions posed as free VPNs while stealing clipboard data through later extension updates.