Gathering detailed insights and metrics for demurgos-foreground-child
Gathering detailed insights and metrics for demurgos-foreground-child
Gathering detailed insights and metrics for demurgos-foreground-child
Gathering detailed insights and metrics for demurgos-foreground-child
npm install demurgos-foreground-child
Typescript
Module System
Min. Node Version
Node Version
NPM Version
68.2
Supply Chain
86.7
Quality
75.2
Maintenance
100
Vulnerability
100
License
TypeScript (83.37%)
JavaScript (15.81%)
Shell (0.82%)
Total Downloads
8,405
Last Day
2
Last Week
25
Last Month
75
Last Year
860
40 Stars
101 Commits
20 Forks
4 Watching
4 Branches
9 Contributors
Latest Version
1.6.0-beta.2
Package Id
demurgos-foreground-child@1.6.0-beta.2
Unpacked Size
42.36 kB
Size
11.35 kB
File Count
8
NPM Version
6.13.6
Node Version
13.7.0
Cumulative downloads
Total Downloads
Last day
-66.7%
2
Compared to previous day
Last week
38.9%
25
Compared to previous week
Last month
-34.2%
75
Compared to previous month
Last year
-19.2%
860
Compared to previous year
3
4
Run a child as if it's the foreground process. Give it stdio.
Mostly this module is here to support some use cases around wrapping child processes for test coverage and such.
1const fg = require('foreground-child') 2 3// cats out this file 4const {child, close} = fg('cat', [__filename]) 5 6// At this point, it's best to just do nothing else. 7// return or whatever. 8// If the child gets a signal, or just exits, then this 9// parent process will exit in the same way. 10 11// Close is a promise resolved when the child is closed. 12// You can use it to inspected its exit code and exit the parent process. 13close.then((close) => { 14 // You can use this handler to perform an action before exiting the 15 // foreground child. 16 console.log(close.code); 17 console.log(close.status); 18 close(); // Kills the parent process using the result of the child process. 19}); 20
The "normal" standard IO file descriptors (0, 1, and 2 for stdin, stdout, and stderr respectively) are shared with the child process. Additionally, if there is an IPC channel set up in the parent, then messages are proxied to the child on file descriptor 3.
However, in Node, it's possible to also map arbitrary file descriptors into a child process. In these cases, foreground-child will not map the file descriptors into the child. If file descriptors 0, 1, or 2 are used for the IPC channel, then strange behavior may happen (like printing IPC messages to stderr, for example).
Note that a SIGKILL will always kill the parent process, and never the child process, because SIGKILL cannot be caught or proxied. The only way to do this would be if Node provided a way to truly exec a process as the new foreground program in the same process space, without forking a separate child process.
The canonical documentation is in the source code. See index.ts.
fg(file, args)
: Original APIfg.compat
: Alias for fg
.fg.spawn(file, args, options)
: New API, based on Node's cp.spawn
.fg.proxy(parent, child)
: Forward IO, IPC and signals from parent to child.No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
3 existing vulnerabilities detected
Details
Reason
Found 5/27 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More