|
1 | 1 | #!/usr/bin/env node
|
2 | 2 | /* eslint-disable no-console */
|
3 | 3 | const shelljs = require('shelljs');
|
4 |
| -const childProcess = require('child_process'); |
| 4 | +const spawnPromise = require('@brandonocasey/spawn-promise'); |
5 | 5 | const path = require('path');
|
6 |
| - |
7 | 6 | const baseDir = path.join(__dirname, '..', 'test', 'fixtures', 'formats');
|
8 | 7 | const DURATION = '0.01s';
|
9 | 8 | const INPUT_FILE = path.join(__dirname, 'big-buck-bunny.mp4');
|
10 | 9 |
|
11 | 10 | shelljs.rm('-rf', baseDir);
|
12 | 11 |
|
13 |
| -const promiseSpawn = function(bin, args, options = {}) { |
14 |
| - process.setMaxListeners(1000); |
15 |
| - |
16 |
| - return new Promise((resolve, reject) => { |
17 |
| - const child = childProcess.spawn(bin, args, options); |
18 |
| - |
19 |
| - let stdout = ''; |
20 |
| - let stderr = ''; |
21 |
| - let out = ''; |
22 |
| - |
23 |
| - child.stdout.on('data', function(chunk) { |
24 |
| - stdout += chunk; |
25 |
| - out += chunk; |
26 |
| - }); |
27 |
| - |
28 |
| - child.stderr.on('data', function(chunk) { |
29 |
| - stderr += chunk; |
30 |
| - out += chunk; |
31 |
| - }); |
32 |
| - |
33 |
| - const kill = () => child.kill(); |
34 |
| - |
35 |
| - process.on('SIGINT', kill); |
36 |
| - process.on('SIGQUIT', kill); |
37 |
| - process.on('exit', kill); |
38 |
| - |
39 |
| - child.on('close', (status) => resolve({ |
40 |
| - cmd: [bin].concat(args), |
| 12 | +const promiseSpawn = function(bin, args, options) { |
| 13 | + return spawnPromise(bin, args, options).then(function({status, combined, stderr, stdout, parameters}) { |
| 14 | + return Promise.resolve({ |
| 15 | + cmd: [parameters[0]].concat(parameters[1]), |
41 | 16 | status,
|
42 |
| - out: out.toString(), |
| 17 | + combined: combined.toString(), |
43 | 18 | stderr: stderr.toString(),
|
44 | 19 | stdout: stdout.toString()
|
45 |
| - })); |
| 20 | + }); |
46 | 21 | });
|
47 | 22 | };
|
48 | 23 |
|
@@ -319,7 +294,7 @@ const promises = Object.keys(containerCodecs).map((container) => {
|
319 | 294 | return resolve(ffmpeg([].concat(codec.args).concat([filePath])).then(function(result) {
|
320 | 295 | if (result.status !== 0) {
|
321 | 296 | console.log(result.cmd.join(' '));
|
322 |
| - console.log(`FAIL: ${fileName} ${result.out}`); |
| 297 | + console.log(`FAIL: ${fileName} ${result.combined}`); |
323 | 298 | return;
|
324 | 299 | }
|
325 | 300 | total++;
|
|
0 commit comments