Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let deadLinksFoundInFile = false;
for (const {link, status, statusCode} of results) {
// Skip links to files that were introduced by the PR.
if (isLinkToFileIntroducedByPR(link)) {
continue;
}
if (status === 'dead') {
deadLinksFoundInFile = true;
log(`[${red('✖')}] ${link} (${red(statusCode)})`);
} else if (!isTravisBuild()) {
log(`[${green('✔')}] ${link}`);
}
}
const filename = markdownFiles[index];
if (deadLinksFoundInFile) {
log(red('ERROR'), 'Possible dead link(s) found in', magenta(filename));
return filename;
}
log(green('SUCCESS'), 'All links in', magenta(filename), 'are alive.');
})
.filter(filenameOrUndef => filenameOrUndef);
'Commands:': 'Commands'
})
.fail((msg, err, yargs) => {
debug(err);
yargs.showHelp();
console.error(`\n${symbols.error} ${ansi.red('ERROR:')} ${msg}`);
process.exit(1);
})
.help('help', 'Show usage information & exit')
.alias('help', 'h')
.version('version', 'Show version number & exit', version)
.alias('version', 'V')
.wrap(process.stdout.columns ? Math.min(process.stdout.columns, 80) : 80)
.epilog(
`Mocha Resources
Chat: ${ansi.magenta(gitter)}
GitHub: ${ansi.blue(repository.url)}
Docs: ${ansi.yellow(homepage)}
`
)
.parserConfiguration(YARGS_PARSER_CONFIG)
.config(args)
.parse(args._);
};
const showErrorCount = (count, type) => {
if (count === 0)
return;
console.log('TypeScript:', colors.magenta(count.toString()), (type !== '' ? type + ' ' : '') + (count === 1 ? 'error' : 'errors'));
hasError = true;
};
showErrorCount(results.transpileErrors, '');
module.exports = function(err, stats) {
if(err) throw new PluginError("webpack", err)
var statColor = stats.compilation.warnings.length < 1 ? 'green' : 'yellow'
if(stats.compilation.errors.length > 0) {
stats.compilation.errors.forEach(function(error){
handleErrors(error)
statColor = 'red'
})
} else {
var compileTime = prettifyTime(stats.endTime - stats.startTime)
log(colors[statColor](stats))
log('Compiled with', colors.cyan('webpack'), 'in', colors.magenta(compileTime))
}
}
function log(message) {
fancyLog(colors.magenta(PLUGIN_NAME), message);
}
magenta(msg: string) {
return color.magenta(msg);
}
.on('unlink', function (file) {
log(colors.magenta(file) + ' is deleted');
watchHandler('deleted', file);
});
generate: function (source, dest, done) {
var uiPath = path.resolve(dest, 'ui');
var apikanaPath = path.resolve(__dirname, '..');
var privateModules = path.resolve(apikanaPath, 'node_modules');
var modulesPath = fs.existsSync(privateModules) ? privateModules : path.resolve('node_modules');
var dependencyPath = path.resolve(params.dependencyPath());
var apiFile = path.resolve(source, params.api());
if (!fs.existsSync(apiFile)) {
log.info('API file ', colors.magenta(source + '/' + params.api()), 'not found, generating one.');
var apiDir = path.dirname(apiFile);
var api = {
swagger: '2.0',
info: {title: path.basename(path.resolve('')), version: '1.0'},
paths: [],
definitions: {$ref: readdir(path.resolve(source, params.models()), apiDir)}
};
fse.mkdirsSync(apiDir);
fs.writeFileSync(apiFile, yaml.stringify(api, 6, 2));
}
function readdir(basedir, relativeTo) {
var res = [];
readdir(basedir, res);
return res;
function schemaInfos(schemas) {
var deps = path.resolve(dependencyPath);
var relDeps = normPath(path.relative(path.resolve(dest, 'model/json-schema'), deps));
var infos = {};
log.debug('Dependencies: ', colors.magenta(normPath(deps)));
for (var name in schemas) {
var schema = schemas[name];
//thank you MS for messing around with filenames!
var filename = normPath(schema.extra.filename);
var source = filename.toLowerCase().startsWith(normPath(deps).toLowerCase())
? (relDeps + '/json-schema-v3' + path.dirname(filename.substring(deps.length + 3)) + '/') : '';
infos[name] = {
source: source,
object: schema.type === 'object' || schema.enum || schema.allOf
};
log.debug('Source file: ', colors.magenta(filename));
log.debug('- as dependency:', colors.magenta(source + name));
}
return infos;
}
function log(event, file) {
event = event[event.length - 1] === 'e' ? event + 'd' : event + 'ed';
var msg = [colors.magenta(file.relative), 'was', event];
if (opts.name) {
msg.unshift(colors.cyan(opts.name) + ' saw');
}
fancyLog.info.apply(null, msg);
}