Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function capturePage () {
attemptsSoFar += 1
ChildProcess.execFile(
Phantom.path,
phantomArguments,
{maxBuffer: 1048576},
function (error, stdout, stderr) {
if (error || stderr) {
// Retry if we haven't reached the max number of capture attempts
if (attemptsSoFar <= maxAttempts) {
return capturePage()
} else {
if (error) throw error
if (stderr) throw stderr
}
}
callback(stdout)
Server.stop()
}
Sites:
https://pngquant.org
https://github.com/imagemin/pngquant-bin
Example:
base:
['-o', output, input]
*/
var array;
if(false != enginepng.png.command){
array = enginepng.png.command.concat(['-o', output, input]);
}else{
array = ['-o', output, input];
}
execFile(pngquant, array, function (err) {
if(option.statistic){
//Block statistic
//- - - - - - - - - - - - - - - - - - - - - - - -
//Узнаем размер файла после сжатия
size_output = getFilesizeInBytes(output);
//Находим на сколько процентов удалось сжать файл
percent = size_output / size_in;
percent = percent * 100;
percent = 100 - percent;
percent = Math.round(percent * 100) / 100;
return callback(size_in, size_output, percent);
//- - - - - - - - - - - - - - - - - - - - - - - -
}
port: PORT
});
var timer;
nc.flush(function() {
nc.subscribe("started", function(m) {
nc.publish("close");
});
timer = setTimeout(function() {
done(new Error("process didn't exit quickly"));
}, 10000);
});
var child = child_process.execFile('node', ['./test/support/exiting_client.js', PORT], function(error) {
if(error) {
nc.close();
done(error);
}
});
child.on('exit', function(code, signal) {
if(timer) {
clearTimeout(timer);
timer = null;
}
nc.close();
if(code !== 0) {
done("Process didn't return a zero code: ", code, signal);
} else {
done();
}
} else {
try {
key = registry('HKLM/Software/VideoLAN/VLC')
} catch (err) {
try {
key = registry('HKLM/Software/Wow6432Node/VideoLAN/VLC')
} catch (e) {
}
}
}
if (key) {
var vlcPath = key['InstallDir'].value + path.sep + 'vlc'
VLC_ARGS = VLC_ARGS.split(' ');
VLC_ARGS.unshift(localHref);
var vlcProc = proc.execFile(vlcPath, VLC_ARGS);
vlcProc.on('close', function (code) {
engine.destroy(function () {
process.exit(0);
})
});
}
}else{
var root = '/Applications/VLC.app/Contents/MacOS/VLC'
var home = (process.env.HOME || '') + root;
var vlc = proc.exec('vlc ' + VLC_ARGS + ' ' + localHref + ' || ' + root + ' ' + VLC_ARGS + ' ' + localHref + ' || ' + home + ' ' + VLC_ARGS + ' ' + localHref, function (error, stdout, stderror) {
if (error) {
process.exit(0)
}
});
if (typeof cb !== "function") cb = uid, uid = null
if (gid == null) gid = process.getgid()
if (uid == null) uid = process.getuid()
if (!isNaN(gid)) gid = gidCache[gid] = +gid
if (!isNaN(uid)) uid = uidCache[uid] = +uid
if (uidCache.hasOwnProperty(uid)) uid = uidCache[uid]
if (gidCache.hasOwnProperty(gid)) gid = gidCache[gid]
if (typeof gid === "number" && typeof uid === "number") {
return process.nextTick(cb.bind(null, null, uid, gid))
}
var getter = require.resolve("./get-uid-gid.js")
child_process.execFile( process.execPath
, [getter, uid, gid]
, function (code, out, err) {
if (er) return cb(new Error("could not get uid/gid\n" + err))
try {
out = JSON.parse(out+"")
} catch (ex) {
return cb(ex)
}
if (out.error) {
var er = new Error(out.error)
er.errno = out.errno
return cb(er)
}
if (isNaN(out.uid) || isNaN(out.gid)) return cb(new Error(
return new Promise(function(resolve, reject) {
var args = ['--silent', '-L', url];
if (cookies) {
args.push('-H', `Cookie: ${cookies}`);
}
require('child_process')
.execFile('curl', args, {encoding: 'utf8', maxBuffer: 1000 * 1024 * 10}, function(error, stdout, stderr) {
if (error) {
reject(error);
} else {
resolve(stdout.toString());
}
});
});
}
this._startServer = new Promise((resolve, reject) => {
let urlRegExp = /http:\/\/localhost:\d+\/\S*/g;
let tokenRegExp = /token=\w+/g;
let baseRegExp = /http:\/\/localhost:\d+\//g;
let home = app.getPath('home');
this._nbServer = execFile(this._info.environment.path, ['-m', 'jupyter', 'notebook', '--no-browser'], { cwd: home });
this._nbServer.on('exit', () => {
this._serverStartFailed();
reject(new Error('Could not find Jupyter in PATH'));
});
this._nbServer.on('error', (err: Error) => {
this._serverStartFailed();
reject(new Error('Could not find Jupyter in PATH'));
});
this._nbServer.stderr.on('data', (serverBuff: string) => {
let urlMatch = serverBuff.toString().match(urlRegExp);
if (!urlMatch) {
return;
}
http://advsys.net/ken/util/pngout.htm
https://github.com/imagemin/pngout-bin
Example:
base:
['input.png', 'output.png']
['input.png', 'output.png', '-s0', '-k0', '-f0']
*/
var array;
if(false != enginepng.png.command){
array = [input, output].concat(enginepng.png.command);
}else{
array = [input, output];
}
execFile(pngout, array, function (err) {
if(err === null){
if(option.statistic){
//Block statistic
//- - - - - - - - - - - - - - - - - - - - - - - -
//Узнаем размер файла после сжатия
size_output = getFilesizeInBytes(output);
//Находим на сколько процентов удалось сжать файл
percent = size_output / size_in;
percent = percent * 100;
percent = 100 - percent;
percent = Math.round(percent * 100) / 100;
return callback(size_in, size_output, percent, null);
//- - - - - - - - - - - - - - - - - - - - - - - -
}
await new Promise((resolve, reject) => {
execFile('node', [
path.join(LH_ROOT, 'lighthouse-cli'),
url,
`-G=${artifactsFolder}`,
], (_, stderr) => {
if (stderr) reject(stderr);
else resolve();
});
});
const trace = fs.readFileSync(`${artifactsFolder}/defaultPass.trace.json`, 'utf-8');
function fsck(device, callback)
{
assert(device);
log(' * #cyan[fsck] ' + device);
var args = ['-y', device];
execFile('/usr/sbin/fsck', args, function(err, stdout, stderr) {
if (err) {
log(' - #red[fsck stdout:] ' + stdout);
log(' - #red[fsck stderr:] ' + stderr);
return callback(err);
}
return callback();
});
}