Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const inputFilename: string = path.resolve(path.join(__dirname, '..', 'assets', 'demo-input.ts'));
console.log('Reading assets/demo-input.ts...');
const inputBuffer: string = fs.readFileSync(inputFilename).toString();
// NOTE: Optionally, can provide a TSDocParserConfiguration here
const tsdocParser: TSDocParser = new TSDocParser();
const parserContext: ParserContext = tsdocParser.parseString(inputBuffer);
console.log(os.EOL + colors.green('Input Buffer:') + os.EOL);
console.log(colors.gray('<<<<<<'));
console.log(inputBuffer);
console.log(colors.gray('>>>>>>'));
console.log(os.EOL + colors.green('Extracted Lines:') + os.EOL);
console.log(JSON.stringify(parserContext.lines.map(x => x.toString()), undefined, ' '));
console.log(os.EOL + colors.green('Parser Log Messages:') + os.EOL);
if (parserContext.log.messages.length === 0) {
console.log('No errors or warnings.');
} else {
for (const message of parserContext.log.messages.map(x => x.toString())) {
console.log(inputFilename + message);
}
}
console.log(os.EOL + colors.green('DocComment parts:') + os.EOL);
const docComment: DocComment = parserContext.docComment;
getFile(path).then(body => {
completed += 1
const hash_github = item.sha
const hash_domain = shagit(body)
if (hash_domain === hash_github) {
console.log(colors.green(`✔ ${hash_github} `) + path)
} else {
incorrect.push(item)
console.log(
colors.red(`✘ ${hash_domain}`) +
` ${path}\n ` +
colors.red(hash_github)
)
}
if (completed === list.length) {
const total_incorrects = incorrect.length
const total_list = list.length
console.log(
colors[total_incorrects === 0 ? 'green' : 'red'].bold(
` ${total_incorrects} fails`
)
function success(txt) {
return console.warn(colors.green(txt));
}
async function uploadFile(resolvedSrc, actualDstPath, nasHttpTriggerPath) {
const fileSize = await getFileSize(resolvedSrc);
const fileOffSetCutByChunkSize = splitRangeBySize(0, fileSize, constants.FUN_NAS_CHUNK_SIZE);
const fileHash = await getFileHash(resolvedSrc);
const filePermission = await getFilePermission(resolvedSrc);
debug(`Creating ${fileSize} bytes size file: ${actualDstPath}`);
await createSizedNasFile(nasHttpTriggerPath, actualDstPath, fileSize);
debug(`${green('✔')} create done`);
await uploadFileByChunk(nasHttpTriggerPath, actualDstPath, resolvedSrc, fileOffSetCutByChunkSize);
await changeNasFilePermission(nasHttpTriggerPath, actualDstPath, filePermission);
debug(`checking uploaded file ${actualDstPath} hash`);
await checkFileHash(nasHttpTriggerPath, actualDstPath, fileHash);
debug(`${green('✔')} hash unchanged`);
console.log(`${green('✔')} upload completed!`);
}
async function spinner(message, fn) {
const oraSpinner = ora(colors.green(message)).start();
try {
await fn(oraSpinner);
oraSpinner.succeed(colors.gray.dim(message));
} catch (error) {
oraSpinner.fail(colors.red(error.toString()));
process.exit(0);
}
}
async function processJob(job) {
console.log(colors.green(`[BUILD] ${job.id} (${job.state}) ${job.message}`));
console.log(colors.yellow(`[-----] ${job.id} ${job.started_at} ${job.commit}`));
const buildInfo = await travis('builds/' + job.id, false);
for (let job of buildInfo.matrix) {
const logFile = 'log-' + job.id + '.txt';
const logExists = fs.existsSync(logFile);
const travisLog = logExists
? { log: fs.readFileSync(logFile).toString() }
: await travis(`jobs/${job.id}`, false);
const log = (travisLog && travisLog.log)? travisLog.log.replace(/\r/g, '\n'): '';
const result = parseLogs(log);
if (!logExists) {
fs.writeFileSync(logFile, log);
}
const status = job.finished_at === null? '(running)': '(finished)';
console.log(' [JOB]', job.id, 'XX:', result.xx, 'BR:', result.br, 'FX:', result.fx, status);
for (let issue of result.issues) {
if (lines.length > 1) {
lines[lines.length - 1] = 'and ' + lines[lines.length - 1];
}
const linesInfo = lines.join(', ');
console.info(
pad2 + colors.bold('Expected'),
'on line' + (lines.length > 1 ? 's' : ''),
linesInfo,
'of',
colors.dim(path.dirname(compareTo) + '/') +
colors.bold(path.basename(compareTo)) +
':\n'
);
console.info(pad4 + firstLinePad, colors.green(header));
console.info(expectedLines.join('\n'));
console.info('\n' + pad2 + colors.bold('Received:\n'));
console.info(pad4 + firstLinePad, colors.red(header));
console.info(actualLines.join('\n'), '\n');
}
}
syncScript.stdout.on('data', (data) => {
const dataString = data.trim();
console.log(colors.green(dataString));
if (dataString === 'Done!') {
resolve({
message: 'success'
});
}
});
function execScript(script, {verbose = false} = {}) {
try {
new ScriptInterpreter({
file: script,
workingDirectory: path.dirname(script),
}).exec();
if (verbose) {
console.info(colors.green('\n\u2713 Script executed successfully!\n'));
} else {
console.info(colors.green('[PASS]'), path.basename(script));
}
} catch (e) {
if (!verbose) {
console.info(colors.red('[FAIL]'), path.basename(script));
return;
}
if (!e.errorData) {
console.info(`Script error:`, e);
return;
}
const {header, errorList, compareTo} = e.errorData;
console.info(colors.red('\nError executing the script:\n'));