Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mediaEmitter.on('CONN_ERROR', code => {
log.error(`ERROR: Unable to connect to Media Player Classic on port ${config.port}. ` +
`Make sure MPC is running, Web Interface is enabled and the port set in 'config.js' file is correct.\n` + code);
// If MPC was previously connected (ie. MPC gets closed while script is running)
// the whole process is killed and restarted by Forever in order to clean MPC Rich Presence
// from user's profile, as destroyRPC() apparently can't do so.
if (active) {
log.warn('WARN: Killing process to clean Rich Presence from your profile...');
process.exit(0);
}
if (mpcServerLoop._onTimeout !== checkMPCEndpoint) {
clearInterval(mpcServerLoop);
mpcServerLoop = setInterval(checkMPCEndpoint, 15000);
}
});
fs.stat(BUILD_PATH, function installScriptExists (err) {
if (err) {
// this should only happen on local install
log.warn(`NOTE: Run 'npx gulp transpile' before using`);
return;
}
require(BUILD_PATH).doInstall().catch(function installError (err) {
log.error(`Error installing Chromedriver: ${err.message}`);
log.error(err.stack ? err.stack : err);
log.error(`Downloading Chromedriver can be skipped by using the ` +
`'--chromedriver-skip-install' flag or ` +
`setting the 'APPIUM_SKIP_CHROMEDRIVER_INSTALL' environment ` +
`variable.`);
process.exit(1);
});
});
});
gulp.task('authenticate', function (done) {
const githubToken = process.env.GITHUB_TOKEN;
if (_.isEmpty(githubToken)) {
log.warn('No GitHub token found in GITHUB_TOKEN environment variable');
return;
}
octokit.authenticate({
type: 'token',
token: githubToken,
});
done();
});
result.warnings().forEach(function (warn) {
fancyLog.warn(warn.toString());
});
styleFile = result.css;
function check () {
i++;
try {
require(BUILD_PATH);
cb();
} catch (err) {
if (err.message.includes(`Cannot find module '${BUILD_PATH}'`)) {
log.warn(`Project does not appear to be built yet. Please run 'npm run chromedriver' first.`);
return cb(new Error(`Could not install module: ${err.message}`));
}
log.warn(`Error trying to install Chromedriver binary. Waiting ${BUILD_RETRY_INTERVAL}ms and trying again: ${err.message}`);
if (i <= BUILD_RETRIES) {
setTimeout(check, BUILD_RETRY_INTERVAL);
} else {
cb(new Error(`Could not import installation module: ${err.message}`));
}
}
}
check();
request(url, (err, response, body) => {
if(err) return done(err);
if(response.statusCode != 200) {
if(response.headers && response.headers['x-ratelimit-remaining'] == 0){
var limit = response.headers['x-ratelimit-limit'];
var resetAt = response.headers['x-ratelimit-reset'] * 1000;
var resetAtDate = new Date(resetAt);
var diff = resetAtDate - new Date();
log.warn('reached gh rate limit of', limit);
log.warn('go sleep', diff / 1000 / 60, 'minutes');
setTimeout(() => {
log.info('awake after sleep');
getRepoInfo(repo, done);
}, diff);
return;
}
else{
return done(new Error('unexpected status code: ' + response.statusCode))
}
};
if(response.statusCode == 200){
return done(null, JSON.parse(body));
}
result.warnings().forEach(function (warn) {
fancyLog.warn(warn.toString());
});
styleFile = result.css;
return (done) => {
const BrowserSync = require('browser-sync');
const bs = BrowserSync.has(buildHash) ? BrowserSync.get(buildHash) : false;
options.isWatching = true; //eslint-disable-line no-param-reassign
const livereload = (d) => {
bs.reload();
d();
};
if (bs === false) {
log.warn(cyan('BrowserSync instance not found. Assets live-reload will not be available.'));
}
list.forEach(({
pattern, task, reload, unlink
}) => {
const tasks = [task];
if (reload && bs) {
tasks.push(livereload);
}
const watcher = gulp.watch(normalizePattern(pattern), gulp.series(...tasks));
if (typeof unlink === 'function') {
watcher.on('unlink', unlink);
}
});
done();
result.warnings().forEach(function (warn) {
log.warn(warn.toString());
});
styleFile = result.css;
function log(mode, ...messages) {
switch (mode) {
case 'verbose':
if (isTravisBuild()) {
return;
}
fancyLog.info(colors.green('VERBOSE:'), ...messages);
break;
case 'info':
fancyLog.info(colors.green('INFO:'), ...messages);
break;
case 'warning':
fancyLog.warn(colors.yellow('WARNING:'), ...messages);
break;
case 'error':
fancyLog.error(colors.red('ERROR:'), ...messages);
break;
case 'fatal':
process.exitCode = 1;
fancyLog.error(colors.red('FATAL:'), ...messages);
throw new Error(messages.join(' '));
case 'travis':
if (isTravisBuild()) {
messages.forEach(message => process.stdout.write(message));
}
break;
}
}