diff --git a/lib/process.js b/lib/process.js index d8e90a8..01ead27 100644 --- a/lib/process.js +++ b/lib/process.js @@ -14,7 +14,11 @@ module.exports = (command, args, opt) => { const childProcess = require('child_process'); const merge = require('merge'); - const finalOpt = merge({'shell': true}, opt); + const defaultOptions = { + 'shell': true, + 'stdio': [process.stdin, 'pipe', 'pipe'], + }; + const finalOpt = merge(defaultOptions, opt); return new Promise((res, rej) => { const proc = childProcess.spawn( [].concat(command).join('&&'), args, finalOpt diff --git a/package.json b/package.json index 5807a53..0460a89 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "simple-process", - "version": "1.0.8", + "version": "1.0.9", "description": "Child process that uses Promise Object", "main": "index.js", "scripts": { diff --git a/tests/unit/test_pyvenv.js b/tests/unit/test_pyvenv.js index ef7b82d..4f86a9f 100644 --- a/tests/unit/test_pyvenv.js +++ b/tests/unit/test_pyvenv.js @@ -30,10 +30,10 @@ }); it('Should call processCall with proper args.', () => { expect(promiseProcessMock.calledOnce).to.be.true; - expect(promiseProcessMock.getCall(0).args[0]).to.eql([ + expect(promiseProcessMock.getCall(0).args).to.eql([[ `. ${path.join(process.cwd(), 'venv', 'bin', 'activate')}`, testCommand, 'deactivate', - ]); + ]]); }); it('The return value should be an instance of promise', () => { expect(ret).to.eql({}); @@ -56,10 +56,10 @@ }); it('Should call processCall with proper args.', () => { expect(promiseProcessMock.calledOnce).to.be.true; - expect(promiseProcessMock.getCall(0).args[0]).to.eql([].concat( + expect(promiseProcessMock.getCall(0).args).to.eql([[].concat( `. ${path.join(process.cwd(), 'venv', 'bin', 'activate')}`, testCommand, 'deactivate' - )); + )]); }); it('The return value should be an instance of promise', () => { expect(ret).to.eql({}); @@ -78,10 +78,10 @@ }); it('Should call processCall with proper args.', () => { expect(promiseProcessMock.calledOnce).to.be.true; - expect(promiseProcessMock.getCall(0).args[0]).to.eql([ + expect(promiseProcessMock.getCall(0).args).to.eql([[ `. ${path.join('test', 'bin', 'activate')}`, testCommand, 'deactivate', - ]); + ]]); }); it('The return value should be an instance of promise', () => { expect(ret).to.eql({}); @@ -100,10 +100,10 @@ }); it('Should call processCall with proper args.', () => { expect(promiseProcessMock.calledOnce).to.be.true; - expect(promiseProcessMock.getCall(0).args[0]).to.eql([ + expect(promiseProcessMock.getCall(0).args).to.eql([[ `. ${path.join('test', 'bin', 'activate')}`, testCommand, 'deactivate', - ]); + ]]); }); it('The return value should be an instance of promise', () => { expect(ret).to.eql({}); diff --git a/tests/unit/test_spawn.js b/tests/unit/test_spawn.js index 90294f5..3ba3986 100644 --- a/tests/unit/test_spawn.js +++ b/tests/unit/test_spawn.js @@ -49,6 +49,7 @@ expect(spawn.callCount).to.equal(1); expect(spawn.calledWithExactly(expectedCommand, undefined, { 'shell': true, + 'stdio': [process.stdin, 'pipe', 'pipe'], })).is.true; }); it('Should assign stdout data event', () => { @@ -72,12 +73,14 @@ const testCommand = 'jugemjugemgokohnosurikire'; const testArgs = ['--kayjare=\'suygyo\'', '--soygyo=\'matsu\'']; beforeEach(() => { - promiseProcess(testCommand, testArgs, {'shell': false}); + promiseProcess( + testCommand, testArgs, {'shell': false, 'stdio': 'pipe'} + ); }); it('Should call spawn with the command', () => { expect(spawn.callCount).to.equal(1); expect(spawn.calledWithExactly(testCommand, testArgs, { - 'shell': false, + 'shell': false, 'stdio': 'pipe', })).is.true; }); it('Should assign stdout data event', () => {