Skip to content

Commit

Permalink
Remove unused function, whoops
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Oct 22, 2019
1 parent f2cf265 commit 636a4a6
Showing 1 changed file with 1 addition and 44 deletions.
45 changes: 1 addition & 44 deletions test/cli.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const pathModule = require('path');
const expect = require('unexpected').clone();

const childProcess = require('child_process');
const expect = require('unexpected').clone();

function consumeStream(stream) {
return new Promise((resolve, reject) => {
Expand All @@ -13,48 +12,6 @@ function consumeStream(stream) {
});
}

async function run(commandAndArgs, stdin) {
if (typeof commandAndArgs !== 'undefined' && !Array.isArray(commandAndArgs)) {
commandAndArgs = [commandAndArgs];
}

const proc = childProcess.spawn(commandAndArgs[0], commandAndArgs.slice(1));

const promises = {
exit: new Promise((resolve, reject) => {
proc.on('error', reject).on('exit', exitCode => {
if (exitCode === 0) {
resolve();
} else {
const err = new Error(`Child process exited with ${exitCode}`);
err.exitCode = exitCode;
reject(err);
}
});
}),
stdin: new Promise((resolve, reject) => {
proc.stdin.on('error', reject).on('close', resolve);
}),
stdout: consumeStream(proc.stdout),
stderr: consumeStream(proc.stderr)
};

if (typeof stdin === 'undefined') {
proc.stdin.end();
} else {
proc.stdin.end(stdin);
}

try {
await Promise.all(Object.values(promises));
return [await promises.stdout, await promises.stderr];
} catch (err) {
err.stdout = await promises.stdout;
err.stderr = await promises.stderr;
throw err;
}
}

async function runSubfont(...args) {
const proc = childProcess.spawn(
pathModule.resolve(__dirname, '..', 'lib', 'cli.js'),
Expand Down

0 comments on commit 636a4a6

Please sign in to comment.