Security News
How Threat Actors are Abusing GitHub’s File Upload Feature to Host Malware
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
spawn-command
Advanced tools
Package description
The spawn-command npm package is a simple wrapper around the child_process.spawn function from Node.js. It allows you to spawn shell commands with ease, handling the intricacies of different operating system command line interfaces. It is particularly useful for running shell commands within Node.js applications.
Spawning shell commands
This feature allows you to spawn a shell command and listen to its output. The example shows how to spawn an 'echo' command and log its output to the console.
const spawnCommand = require('spawn-command');
const child = spawnCommand('echo Hello World');
child.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
Handling command completion
This feature allows you to handle the completion of a shell command. The example demonstrates how to spawn a 'ls -la' command and log the exit code once the command completes.
const spawnCommand = require('spawn-command');
const child = spawnCommand('ls -la');
child.on('close', function (code) {
console.log('child process exited with code ' + code);
});
This is a core Node.js module that provides the ability to spawn subprocesses. It is more complex and lower-level than spawn-command, but it offers more control and flexibility.
Execa is a popular npm package that provides a better user experience than the default child_process module. It supports synchronous and asynchronous execution, returns a promise, and has better support for Windows command line parsing.
Cross-spawn is an npm package that aims to provide a cross-platform solution for spawning shell commands. It handles command line argument escaping and path issues on Windows, making it more robust than spawn-command for complex use cases.
Readme
Spawn commands like child_process.exec
does but return a ChildProcess
.
npm install spawn-command
var spawnCommand = require('spawn-command'),
child = spawnCommand('echo "Hello spawn" | base64');
child.stdout.on('data', function (data) {
console.log('data', data);
});
child.on('exit', function (exitCode) {
console.log('exit', exitCode);
});
FAQs
Spawn commands like `child_process.exec` does but return a `ChildProcess`
The npm package spawn-command receives a total of 3,504,620 weekly downloads. As such, spawn-command popularity was classified as popular.
We found that spawn-command 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
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.