Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should log to console', () => {
const helper = new MigrationUtils(
EDirection.up,
null as any,
loggerMock as any,
);
// tslint:disable-next-line: no-string-literal
helper['loggerHelper'](loggerMock)('test');
expect(loggerMock.log).toBeCalledTimes(1);
expect(loggerMock.log).toBeCalledWith(
' '.repeat(8),
chalk.inverse(' LOGGER '),
'test',
);
});
});
function renderHeader(statuses) {
var txt = '';
// Build Header
for (var k in statuses) {
var status = statuses[k];
// Create header
var col = centerText(k, width);
// Set header status color
if (status === false) {
col = chalk.dim(col);
} else {
col = chalk.white(col);
}
txt += col;
}
return txt;
}
async function prepareNpmPackage({ name, dir }) {
try {
await Promise.all([
asyncCopyTo(`LICENSE`, `${destination}/${name}/LICENSE`),
asyncCopyTo(`${dir}/package.json`, `${destination}/${name}/package.json`),
(async () => {
if (!existsSync(`${dir}/README.md`)) {
throw Error(`Missing README.md file in "${name}" package.`);
}
await asyncCopyTo(`${dir}/README.md`, `${destination}/${name}/README.md`);
})()
]);
} catch (e) {
// eslint-disable-next-line
console.log(chalk.red(e.message));
process.exit(1);
}
const tgzName = (await asyncExecuteCommand(`npm pack ${destination}/${name}`)).trim();
await asyncRimRaf(`${destination}/${name}`);
await asyncExtractTar(getTarOptions(tgzName, name));
unlinkSync(tgzName);
}
var path = require('path');
var resolve = require('resolve');
var program = require('commander');
var chalk = require('chalk');
var semver = require('semver');
var updateNotifier = require('./update-notifier');
var pkg = require('../package.json');
var argvs = process.argv;
var command = argvs[2];
// check nodejs version
if (!semver.satisfies(process.version, pkg.engines.node)) {
console.log(chalk.red.bold('Require nodejs version ' + pkg.engines.node + ', current ' + process.version));
console.log('Download the latest nodejs here ' + chalk.green('https://nodejs.org/en/download/'));
process.exit();
}
// program definiation
program
.version(pkg.version)
.usage(' [options]');
// dirs to find plugins
var moduleDirs = [
path.join(__dirname, '..', 'node_modules'),
path.join(__dirname, '..', '..')
];
program._moduleDirs = moduleDirs;
// locate the plugin
.fail(function (msg, err, yargs) {
if (err) throw err // preserve stack
console.info(bgRed('You broke it!'))
console.info(red(msg))
console.error(green('You should be doing'), yargs.help())
process.exit(1)
}).argv
debug(argv)
debug('Git rev-parse command returned:')
debug(` --show-top-level: ${topLevel}`)
debug(` --git-common-dir: ${gitCommonDir}`)
// Install or uninstall
if (action === 'install') {
install(topLevel, gitCommonDir, huskyDir, isCI)
} else {
uninstall(gitCommonDir, huskyDir)
}
console.log(`husky > Done`)
} catch (error) {
console.log(chalk.red(error.message.trim()))
console.log(chalk.red(`husky > Failed to ${action}`))
}
process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection at: Promise ', p, ' reason: ', reason);
kill();
});
}
// 初始化参数
eslint.initParams({ ...globalParams });
stylelint.initParams({ ...globalParams });
// run
console.log(green('\nrunning lint\n'));
const eslintExitCode = eslint.exec();
const stylelintExitCode = stylelint.exec();
console.log(eslintExitCode ? red('eslint unpassed') : green('eslint passed!'), '; ', stylelintExitCode ? red('stylelint unpassed') : green('stylelint passed!'));
writeStatusFile({ eslintExitCode, stylelintExitCode, statusResultSrcFile });
ncp.copy(lintResultIndexFile, () => {
console.log(green(`\nresult page has be created and url was copied, you can paste directly to browser address area to see result: ${lintResultIndexFile}\n`));
});
};
parser.parseString(data, function (err, result) {
if(err) {
reject(chalk.red('parsing error, failed to parse ')+ValuesFile);
} else {
// find and replace app name
for (var i = result.resources.string.length - 1; i >= 0; i--) {
if (result.resources.string[i]['$'].name === 'app_name') {
result.resources.string[i]._ = app_name;
console.log(result.resources.string[i]);
}
}
// rebuild xml from js Object
let xml = builder.buildObject(result);
fs.writeFile(ValuesFile, xml, function (err, data) {
if (err) throw err;
function parserFunction(className, key, fileName) {
if(debug) console.log('parsing: '+chalk.blue(className)+' '+chalk.cyan(key)+' '+chalk.green(fileName))
// checking if function already exists, if not also add name without class
if(className == 'function') {
parserAbstractFunction(key, fileName);
parserAbstractFunction('function.'+key, fileName);
}
else if(className != 'class') {
parserAbstractFunction(className + '.' + key, fileName, className);
}
if( typeof mapping[key] == 'undefined' && !fs.existsSync(DOC_DIR + '/function.' + key + '.html') ) {
mapping[key] = 1;
parserAbstractFunction(key, fileName);
}
}
async function buildHTML(state) {
const {
routes,
config: { paths, maxThreads },
} = state
time(chalk.green('[\u2713] HTML Exported'))
// in case of an absolute path for DIST we must tell node to load the modules
// from our project root
if (!paths.DIST.startsWith(paths.ROOT)) {
process.env.NODE_PATH = paths.NODE_MODULES
require('module').Module._initPaths()
}
// Single threaded export
if (maxThreads <= 1) {
console.log('Exporting HTML...')
await require('./exportRoutes.sync').default(state)
} else {
// Multi-threaded export
const threads = Math.min(cores, maxThreads)
const htmlProgress = progress(routes.length)