diff --git a/src/shell.js b/src/shell.js index dafec67cd..5432cc737 100644 --- a/src/shell.js +++ b/src/shell.js @@ -2,7 +2,8 @@ exports = module.exports = { sudo: sudo, - exec: exec + exec: exec, + execSync: execSync }; var assert = require('assert'), @@ -13,6 +14,13 @@ var assert = require('assert'), var SUDO = '/usr/bin/sudo'; +function execSync(tag, cmd) { + assert.strictEqual(typeof tag, 'string'); + assert.strictEqual(typeof cmd, 'string'); + + child_process.execSync(cmd, { stdio: 'inherit' }); +} + function exec(tag, file, args, callback) { assert.strictEqual(typeof tag, 'string'); assert.strictEqual(typeof file, 'string'); diff --git a/src/test/shell-test.js b/src/test/shell-test.js index 1f09632f7..ac17f7f06 100644 --- a/src/test/shell-test.js +++ b/src/test/shell-test.js @@ -47,5 +47,20 @@ describe('shell', function () { done(); }); }); + + it('execSync a valid program', function (done) { + shell.execSync('test', 'ls -l | wc -c'); + done(); + }); + + it('execSync throws for invalid program', function (done) { + expect(function () { shell.execSync('test', 'cannotexist') }).to.throwException(); + done(); + }); + + it('execSync throws for failed program', function (done) { + expect(function () { shell.execSync('test', 'false'); }).to.throwException(); + done(); + }); });