MCPcopy Index your code
hub / github.com/shelljs/shelljs / _exec

Function _exec

src/exec.js:215–254  ·  view source on GitHub ↗
(command, options, callback)

Source from the content-addressed store, hash-verified

213//@ **command injection**. For more context, consult the [Security
214//@ Guidelines](https://github.com/shelljs/shelljs/wiki/Security-guidelines).
215function _exec(command, options, callback) {
216 options = options || {};
217
218 var pipe = common.readFromPipe();
219
220 // Callback is defined instead of options.
221 if (typeof options === 'function') {
222 callback = options;
223 options = { async: true };
224 }
225
226 // Callback is defined with options.
227 if (typeof options === 'object' && typeof callback === 'function') {
228 options.async = true;
229 }
230
231 options = common.extend({
232 silent: common.config.silent,
233 fatal: common.config.fatal,
234 async: false,
235 }, options);
236
237 if (!command) {
238 try {
239 common.error('must specify command');
240 } catch (e) {
241 if (options.fatal) {
242 throw e;
243 }
244
245 return;
246 }
247 }
248
249 if (options.async) {
250 return execAsync(command, options, pipe, callback);
251 } else {
252 return execSync(command, options, pipe);
253 }
254}
255module.exports = _exec;

Callers

nothing calls this directly

Calls 2

execSyncFunction · 0.85
execAsyncFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…