Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// var input = prefs.file.input;
var w = prefs.dimensions.width || 320;
var h = prefs.dimensions.height || 240;
var fps = prefs.fps || 24;
var stats = prefs.color.stats_mode || 'full';
// var colors = prefs.color.colors || 256;
var transparency = (prefs.color.alpha?1:0) || 0;
var colors = prefs.color.count || 256;
var scaleCmd = "scale="+w+":"+h;
var vf = util.format("fps=%s,%s:flags=lanczos,palettegen=stats_mode=%s:max_colors=%s:reserve_transparent=%s", fps, scaleCmd, stats, colors, transparency);
if(ffmpeg_ps) ffmpeg_ps.kill();
ffmpeg_ps = spawn(ffmpeg_path, ["-i", input, "-vf", vf, "-f", "image2", "-vcodec", "png", "pipe:1"])
var data = [];
ffmpeg_ps.stdout.on('data',function(d){
data.push(d);
});
ffmpeg_ps.stderr.on('data',function(d){
// console.log("stderr",d.toString());
});
ffmpeg_ps.on('close',function(){
event.sender.send('paletteResult', Buffer.concat(data).toString('base64'));
});
})
ipcMain.on('cancelProcess', (event,opts) => {
_decodeSilk(input, frequency, callback) {
var output = this._getTempFile(input + ".pcm"),
decoder = spawn(this._getSilkSDK("decoder"), [input, output, "-Fs_API", frequency]);
// Allow it to output
decoder.stdout.on('data', (data) => { });
decoder.stderr.on('data', (data) => { });
decoder.on('close', (code) => {
if (code == 1) { // Error occured
callback();
} else { // Success
callback(output);
}
});
}
cb = cleanup.callback;
} else if (operation === 'vectorRoot') {
var cleanup = clean.cleanVector(a, b, cb, x);
a = cleanup.func;
b = JSON.stringify(cleanup.options);
cb = cleanup.callback;
} else if (operation === 'derivative') {
var cleanup = clean.cleanDerivative(a, b, cb, x);
a = cleanup.func;
b = JSON.stringify(cleanup.options);
cb = cleanup.callback;
}
// don't need to worry about race conditions with async process below
// since each is wrapped in their own "runPython" closure
var python = require('child_process').spawn(
'python',
[__dirname + '/../py/exec.py', operation, a, b]);
var output = '';
python.stdout.on('data', function (data){
output += data;
});
python.stdout.on('close', function (){
try {
cb(JSON.parse(output));
} catch (e) {
cb(output);
}
});
}
portastic.find({ min: 9200, max: 9300 }).then(function (ports) {
var port = ports[0];
server = child_process.spawn(appiumBinary, ["-p", port, "--no-reset"], { detached: false });
server.stdout.on("data", function (data) {
logOut("" + data);
});
server.stderr.on("data", function (data) {
logErr("" + data);
});
server.on('exit', function (code) {
server = null;
logOut('Appium Server process exited with code ' + code);
process.exit();
});
waitForOutput(server, /listener started/, 60000).then(function () {
process.env.APPIUM_PORT = port;
tests = child_process.spawn(mochaBinary, mochaOpts, { shell: true, detached: false, env: getTestEnv() });
exec('npm install --production --force', function (err, stdout, stderr) {
if (err) {
console.error(err);
process.exit(1);
}
console.log('\nBuilding node-ios-device binaries');
var nodeIosDeviceDir = path.join(titaniumDir, 'node_modules', 'node-ios-device');
var child = spawn('sh', [ path.join(nodeIosDeviceDir, 'bin', 'build-all.sh') ], { cwd: nodeIosDeviceDir, stdio: 'inherit' });
child.on('close', function (code) {
if (code) {
console.error('Error: Failed to build node-ios-device');
process.exit(1);
}
rm(path.join(nodeIosDeviceDir, 'build'));
console.info('\nCompleted successfully!');
process.exit(0);
});
});
});
return new Promise((resolve, reject) => {
let args = [
'push',
resource
];
child.spawn('docker', args, { stdio: 'inherit' })
.on('exit', (code, signal) => {
if (signal || code) reject(signal || code);
else resolve();
});
});
}
return new Promise((resolve, reject) => {
const cp = spawn(cmd, args, {
cwd: path.join(__dirname, '..'),
env: {
...process.env,
...env
},
shell: true
});
cp.stdout.on('data', data => {
stdout.write(data);
});
cp.stderr.on('data', data => {
stderr.write(data);
});
cp.on('close', code => {
if (code) {
reject();
function openDetachedExternal(url) {
const spawnOption = {detached: true, stdio: 'ignore'};
switch (process.platform) {
case 'win32':
return spawn('cmd', ['/C', 'start', url], spawnOption);
case 'darwin':
return spawn('open', [url], spawnOption);
case 'linux':
return spawn('xdg-open', [url], spawnOption);
default:
return null;
}
}
return new Promise(function (resolve, reject) {
var child = spawn(command, options, {
cmd: cmd,
env: process.env,
stdio: 'inherit'
});
child.on('exit', function (code) {
if (code === 0) {
resolve(true);
} else {
reject(new Error('Error code: ' + code));
}
});
});
}
let spawnProcess = function (command: string, host: string, options: string[], cb ?: (result: string | number) => void) {
let child = null;
if (env === Constants.RESERVED.ENV_DEV) {
child = cp.spawn(command, options);
let prefix = command === Constants.COMMAND.SSH ? '[' + host + '] ' : '';
child.stderr.on('data', function (chunk) {
let msg = chunk.toString();
process.stderr.write(msg);
if (!!cb) {
cb(msg);
}
});
child.stdout.on('data', function (chunk) {
let msg = prefix + chunk.toString();
process.stdout.write(msg);
});
} else {
child = cp.spawn(command, options, { detached: true, stdio: 'inherit' });