shell: add explicit bash() function
This commit is contained in:
@@ -64,14 +64,17 @@ describe('shell', function () {
|
||||
const [error] = await safe(shell.spawn('sleep', ['20'], { timeout: 1000 }));
|
||||
expect(error.reason).to.be(BoxError.SHELL_ERROR);
|
||||
});
|
||||
});
|
||||
|
||||
it('cannot exec a shell program by default', async function () {
|
||||
const [error] = await safe(shell.exec('ls -l | wc -c', {}));
|
||||
expect(error.reason).to.be(BoxError.SHELL_ERROR);
|
||||
describe('bash', function () {
|
||||
it('can bash a shell program', async function () {
|
||||
const out = await shell.bash('ls -l | wc -c', {});
|
||||
expect(Buffer.isBuffer(out)).to.be(true);
|
||||
});
|
||||
|
||||
it('cannot exec a shell program b', async function () {
|
||||
await shell.exec('ls -l | wc -c', { shell: '/bin/bash' });
|
||||
it('can bash a shell program', async function () {
|
||||
const out = await shell.bash('ls -l | wc -c', { encoding: 'utf8' });
|
||||
expect(out).to.be.a('string');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user