Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
gulp.task('upload', function () {
let tempDir;
// Find the latest bundle
log.info('Retrieving asset and uploading to Sauce Storage');
return support.tempDir.openDir()
.then(function (dir) {
log.info(`Temporary directory for download: '${dir}'`);
tempDir = dir;
})
.then(function () {
return octokit.repos.getLatestRelease({owner, repo});
})
.then(function (res) {
// go through the assets and fine the correct one
for (const asset of res.data.assets) {
if (ASSET_NAME_REGEXP.test(asset.name)) {
log.info(`Downloading asset from '${asset.browser_download_url}'`);
return asset.browser_download_url;
}
}
// Remove a dynamic import for rules (I suspect this is a dead code).
{
match: /eslint(\/|\\)lib(\/|\\)linter(\/|\\)rules\.js$/u,
test: /require\(this\._rules\[ruleId\]\)/u,
replace: "null",
},
],
}),
json({ preferConst: true }),
commonjs(),
sourcemaps(),
],
})
//--------------------------------------------------------------------------
log.info("Generate file contents.")
const { output } = await bundle.generate({
format: "cjs",
sourcemap: true,
})
//--------------------------------------------------------------------------
log.info("Minify file contents.")
const promises = []
for (const { code: rawCode, fileName, map: rawMap } of output) {
log.info("- %s", fileName)
const filePath = path.join("dist", fileName)
const { code, map } = babel.transform(rawCode, {
clientID = '427863248734388224';
let mediaEmitter = new events.EventEmitter(),
active = false,
discordRPCLoop,
mpcServerLoop,
rpc;
// Checks if port set in config.js is valid.
if (isNaN(config.port)) {
throw new Error('Port is empty or invalid! Please set a valid port number in \'config.js\' file.');
}
const uri = `http://localhost:${config.port}/variables.html`;
log.info('INFO: Fully ready. Trying to connect to Discord client...');
// When it succesfully connects to MPC Web Interface, it begins checking MPC
// every 5 seconds, getting its playback data and sending it to Discord Rich Presence
// through updatePresence() function from core.js.
mediaEmitter.on('CONNECTED', res => {
clearInterval(mpcServerLoop);
mpcServerLoop = setInterval(checkMPCEndpoint, 5000);
if (!active) {
log.info(`INFO: Connected to ${res.headers.server}`);
}
active = updatePresence(res, rpc);
});
// When connection to MPC fails it attempts to connect
// to MPC again every 15 seconds.
mediaEmitter.on('CONN_ERROR', code => {
const tapSummarize = require('tap-summary')
const glob = require('glob')
const log = require('fancy-log')
const packageJson = require('./package.json')
const defaultOptions = {
minify: false,
importance: null,
write: false,
version: null
}
const options = minimist(process.argv.slice(2), {default: defaultOptions})
log.info('Options:', options)
gulp.task('clean:js', (cb) => {
return del(['dist/*.js', 'dist/*.js.map'])
})
gulp.task('stylus', () => {
gulp.src('src/styles/styl/main.styl')
.pipe(plugins.plumber()) // with the plumber the gulp task won't crash on errors
.pipe(plugins.stylus({
use: [nib()],
errors: true
}))
// https://github.com/ai/autoprefixer#browsers
.pipe(plugins.autoprefixer(
'last 5 versions',
'> 1%',
export async function processProject(
files: string[],
passedOptions?: TopLevelOptions,
passedLocator?: GeneratorLocator,
passedReporter?: Reporter
) {
const options = passedOptions || defaultOptions
const reporter = passedReporter || new ConsoleReporter(options.reporter)
const locator = passedLocator || new GeneratorLocator({ ...options.locator, reporter })
debug("Bootstrapping project")
await locator.bootstrap()
log.info(`Processing ${files.length} file(s)`)
await Promise.all(
files.map(async (f: string) =>
new TemplateProcessor(f, options, { reporter, locator }).process()
)
)
reporter.reportAllWarnings()
}
;(async () => {
//--------------------------------------------------------------------------
log.info("Check if updates exist.")
try {
await exec("git", "diff", "--exit-code", "--quiet")
log.info("Up to date.")
return
} catch (_) {
log.info("Updates exist.")
}
//--------------------------------------------------------------------------
log.info("Make a commit.")
const pkg = await fs.readJSON("package.json")
await exec("git", "add", ".")
await exec("git", "commit", "-m", `"🔖 ${pkg.version}"`)
//--------------------------------------------------------------------------
log.info("Make a tag.", pkg.version)
await exec("git", "tag", pkg.version)
//--------------------------------------------------------------------------
log.info("Push those.", pkg.version)
await exec(
"git",
"push",
`https://mysticatea:${TOKEN}@github.com/mysticatea/eslint4b.git`,
mediaEmitter.on('discordConnected', () => {
clearInterval(discordRPCLoop);
log.info('INFO: Connected to Discord. Listening MPC on ' + uri);
checkMPCEndpoint();
mpcServerLoop = setInterval(checkMPCEndpoint, 15000);
});
gulp.task('clean:build', () => {
log.info('Deleting build folder');
return gulp.src(baseConfig.dir.build)
.pipe(rimraf());
});
var server = app.listen(global.config.server.http.port, global.config.server.ip, function() {
var host = server.address().address;
var port = server.address().port;
log.info(">>>>>> HTTP server is listening on " + host + ":" + port + " <<<<<<");
});
var getCode = function (source, options) {
var code;
if (options.debug) {
fancyLog.info("reading source code");
}
try {
code = fs_1.readFileSync(source);
if (options.debug) {
fancyLog.info("code fetched from " + source);
}
code = code.toString();
}
catch (exception) {
fancyLog.info("plain code read");
code = source;
}
return code;
};
/**