
Security News
New CVE Forecasting Tool Predicts 47,000 Disclosures in 2025
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
promised-exec
Advanced tools
Promised version of NodeJS child_process exec.
To install this module use following command at root path of your module:
npm install promised-exec --save
This module exports function which waits only one argument on input: string with terminal command.
Function returns promise (based on library "q").
If command is invalid, the catch
function will be called with object which contains string with error, and default error buffer (argument error of exec callback).
If command is valid, but response of command is error, the catch
function will be called with object which contains string with error, and default error buffer (argument error of exec callback).
If command is valid, and response is correct, the the
function will be called with string which contains response of command.
Example (correct command):
var exec, promise;
exec = require('promised-exec');
promise = exec('ls -l');
promise.then(function (responseString) {
/*
* Now variable 'responseString' contains string:
*
* "-rwxrwxrwx 1 root root 29 ะดะตะบ 6 09:58 config.json
* -rwxrwxrwx 1 root root 142 ะดะตะบ 6 09:58 gulpfile.js
* -rwxrwxrwx 1 root root 224 ะดะตะบ 6 09:58 gulptask.test.js
* -rwxrwxrwx 1 root root 796 ะดะตะบ 6 10:34 index.js
* -rwxrwxrwx 1 root root 1093 ะดะตะบ 6 09:58 LICENSE
* drwxrwxrwx 1 root root 0 ะดะตะบ 6 09:59 node_modules
* -rwxrwxrwx 1 root root 713 ะดะตะบ 6 09:58 package.json
* -rwxrwxrwx 1 root root 3051 ะดะตะบ 6 10:51 README.md
* drwxrwxrwx 1 root root 0 ะดะตะบ 6 10:35 tests"
*
*/
});
. . .
Example (incorrect command):
var exec, promise;
exec = require('promised-exec');
promise = exec('some-unknown-command');
promise.catch(function (errorObject) {
/*
* Now variable 'errorObject' contains object:
*
* {"buffer": <Buffer>,"string":"Error: Command failed: /bin/sh: some-unknown-command: command not found\n"}
*
*/
});
. . .
Example (incorrect command arguments):
var exec, promise;
exec = require('promised-exec');
promise = exec('ls -w');
promise.catch(function (errorObject) {
/*
* Now variable 'errorObject' contains object:
*
* {"buffer": <Buffer>,"string":"Error: Command failed: ls: key must be used with argument \"w\"\nUse command \"ls --help\" to get additional information.\n"}
*
*/
});
. . .
FAQs
Promised execution of terminal command.
The npm package promised-exec receives a total of 75 weekly downloads. As such, promised-exec popularity was classified as not popular.
We found that promised-exec 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
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.