Skip to content

Commit 873b43f

Browse files
committed
chore: switch generate-formats to shared @brandonocasey/spawn-promise
1 parent aafcd42 commit 873b43f

File tree

3 files changed

+19
-34
lines changed

3 files changed

+19
-34
lines changed

bin/generate-formats.js

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,23 @@
11
#!/usr/bin/env node
22
/* eslint-disable no-console */
33
const shelljs = require('shelljs');
4-
const childProcess = require('child_process');
4+
const spawnPromise = require('@brandonocasey/spawn-promise');
55
const path = require('path');
6-
76
const baseDir = path.join(__dirname, '..', 'test', 'fixtures', 'formats');
87
const DURATION = '0.01s';
98
const INPUT_FILE = path.join(__dirname, 'big-buck-bunny.mp4');
109

1110
shelljs.rm('-rf', baseDir);
1211

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]),
4116
status,
42-
out: out.toString(),
17+
combined: combined.toString(),
4318
stderr: stderr.toString(),
4419
stdout: stdout.toString()
45-
}));
20+
});
4621
});
4722
};
4823

@@ -319,7 +294,7 @@ const promises = Object.keys(containerCodecs).map((container) => {
319294
return resolve(ffmpeg([].concat(codec.args).concat([filePath])).then(function(result) {
320295
if (result.status !== 0) {
321296
console.log(result.cmd.join(' '));
322-
console.log(`FAIL: ${fileName} ${result.out}`);
297+
console.log(`FAIL: ${fileName} ${result.combined}`);
323298
return;
324299
}
325300
total++;

package-lock.json

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,11 @@
8686
},
8787
"devDependencies": {
8888
"@babel/cli": "^7.12.8",
89+
"@brandonocasey/spawn-promise": "~0.2.0",
8990
"@videojs/babel-config": "^0.2.0",
9091
"@videojs/generator-helpers": "~2.0.1",
91-
"rollup": "^2.28.2",
9292
"karma": "^5.2.3",
93+
"rollup": "^2.28.2",
9394
"videojs-generate-karma-config": "~7.0.0",
9495
"videojs-generate-rollup-config": "~6.0.0",
9596
"videojs-generator-verify": "~3.0.3",

0 commit comments

Comments
 (0)