Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
through.obj((file, env, cb) => {
try {
file.contents = Buffer.from(
transform({
file,
type,
}),
);
// .jsx -> .js
file.path = file.path.replace(extname(file.path), '.js');
cb(null, file);
} catch (e) {
signale.error(`Compiled faild: ${file.path}`);
cb(null);
}
}),
),
await mkdir(`${basePath}/data`, { recursive: true });
} catch (e) {
// logger.info(`${basePath}/data already existed. But that's ok`);
}
try {
await mkdir(workPath, { recursive: true });
} catch (e) {
// logger.info(`workPath already existed. But that's ok`);
}
try {
await mkdir(codePath, { recursive: true });
await mkdir(logPath, { recursive: true });
} catch (e) {
logger.error(e);
}
return {
workPath,
codePath,
logPath
};
}
await crawler.crawl(modification)
} catch (e) {
if (e instanceof NAError) { // Not applicable stands for parameters not enough
signale.debug(`${siteInfo.address} - ${crawler_name} NA`)
return
}
signale.error(`An error appeared in ${crawler_name}`, e)
}
})()
}
}
}
await (new PromisePool(promiseGenerator, parseInt(process.env.Concurrency) || 3)).start()
await DataBase.updateSite(modification, doc["_id"])
} catch (e) {
signale.error(`Unknown error in ${siteInfo.address}`, e)
}
}
function commitLint() {
const gitParams = process.env.HUSKY_GIT_PARAMS;
const commitMsg = fs.readFileSync(gitParams, 'utf-8').trim();
if (!commitRE.test(commitMsg)) {
signale.error(`Error: invalid commit message: "${commitMsg}".
Proper commit message format is required for automated changelog generation.
Examples:
- fix(Button): incorrect style
- feat(Button): incorrect style
- docs(Button): fix typo
Allowed Types:
- fix
- feat
- docs
- perf
- test
fs.appendFile(`${job.path.logs}/${stepName}.log`, msg, err => {
if (err) throw err;
if (step.syslog.broadcasting) {
return;
}
step.syslog.broadcasting = true;
let cmd = `npx websocketdjs --port ${step.port} tail -f ${job.path.logs}/${stepName}.log`;
logger.debug(cmd);
try {
execa.command(cmd), { shell: true };
} catch (e) {
logger.error("Failed to run websocketdjs");
logger.error(cmd);
logger.error(e);
process.exit(1);
}
});
});
function getImage(job) {
let imageMap = {
"ubuntu-latest": "phishy/wflow-ubuntu-latest"
};
if (!(job["runs-on"] in imageMap)) {
logger.error(`Unsupported runs-on in ${job.id} (ubuntu-latest only)`);
process.exit(1);
}
return imageMap[job["runs-on"]];
}
watcher.on('event', event => {
const { code, error } = event;
switch (code) {
case 'START':
signale.info('Rebuild since file changed');
break;
case 'ERROR':
signale.error(error);
default:
break;
}
});
}
res.end = function(chunk) {
if (chunk) chunks.push(Buffer.from(chunk));
const body = Buffer.concat(chunks).toString('utf8');
try {
const harContent = buildHar(req, res, body, apiCall, apiConfig.name);
fs.writeFileSync(apiRecordPath, JSON.stringify(harContent, null, 2), {
encoding: 'utf8',
});
} catch (error) {
signale.error(error);
signale.error(`Impossible to create .har from response to ${apiCall}`);
}
oldEnd.apply(res, arguments);
};
runner.on('close', code => {
if (code) {
signale.error(`Error on execution: ${cmd} ${(args || []).join(' ')}`);
reject(code);
return;
}
resolve();
});
});