Skip to content

Commit

Permalink
chore: switch generate-formats to shared @brandonocasey/spawn-promise
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey committed Aug 18, 2021
1 parent aafcd42 commit 873b43f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 34 deletions.
41 changes: 8 additions & 33 deletions bin/generate-formats.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,23 @@
#!/usr/bin/env node
/* eslint-disable no-console */
const shelljs = require('shelljs');
const childProcess = require('child_process');
const spawnPromise = require('@brandonocasey/spawn-promise');
const path = require('path');

const baseDir = path.join(__dirname, '..', 'test', 'fixtures', 'formats');
const DURATION = '0.01s';
const INPUT_FILE = path.join(__dirname, 'big-buck-bunny.mp4');

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

const promiseSpawn = function(bin, args, options = {}) {
process.setMaxListeners(1000);

return new Promise((resolve, reject) => {
const child = childProcess.spawn(bin, args, options);

let stdout = '';
let stderr = '';
let out = '';

child.stdout.on('data', function(chunk) {
stdout += chunk;
out += chunk;
});

child.stderr.on('data', function(chunk) {
stderr += chunk;
out += chunk;
});

const kill = () => child.kill();

process.on('SIGINT', kill);
process.on('SIGQUIT', kill);
process.on('exit', kill);

child.on('close', (status) => resolve({
cmd: [bin].concat(args),
const promiseSpawn = function(bin, args, options) {
return spawnPromise(bin, args, options).then(function({status, combined, stderr, stdout, parameters}) {
return Promise.resolve({
cmd: [parameters[0]].concat(parameters[1]),
status,
out: out.toString(),
combined: combined.toString(),
stderr: stderr.toString(),
stdout: stdout.toString()
}));
});
});
};

Expand Down Expand Up @@ -319,7 +294,7 @@ const promises = Object.keys(containerCodecs).map((container) => {
return resolve(ffmpeg([].concat(codec.args).concat([filePath])).then(function(result) {
if (result.status !== 0) {
console.log(result.cmd.join(' '));
console.log(`FAIL: ${fileName} ${result.out}`);
console.log(`FAIL: ${fileName} ${result.combined}`);
return;
}
total++;
Expand Down
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@
},
"devDependencies": {
"@babel/cli": "^7.12.8",
"@brandonocasey/spawn-promise": "~0.2.0",
"@videojs/babel-config": "^0.2.0",
"@videojs/generator-helpers": "~2.0.1",
"rollup": "^2.28.2",
"karma": "^5.2.3",
"rollup": "^2.28.2",
"videojs-generate-karma-config": "~7.0.0",
"videojs-generate-rollup-config": "~6.0.0",
"videojs-generator-verify": "~3.0.3",
Expand Down

0 comments on commit 873b43f

Please sign in to comment.