Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fs.writeFileSync(ROLLUP_INPUT_FILE, `${requires}\n\n${esmExportString}`);
const testExports = `module.exports = {${[...snippetsArray, ...archivedSnippetsArray]
.map(v => v.id)
.join(',')}}`;
fs.writeFileSync(
TEST_MODULE_FILE,
`${requires}\n\n${cjsExportString}\n\n${testExports}`
);
// Check Travis builds - Will skip builds on Travis if not CRON/API
if (util.isTravisCI() && util.isNotTravisCronOrAPI()) {
fs.unlink(ROLLUP_INPUT_FILE);
console.log(
`${green(
'NOBUILD'
)} Module build terminated, not a cron job or a custom build!`
);
console.timeEnd('Packager');
process.exit(0);
}
await doRollup();
// Clean up the temporary input file Rollup used for building the module
fs.unlink(ROLLUP_INPUT_FILE);
console.log(`${green('SUCCESS!')} Snippet module built!`);
console.timeEnd('Packager');
} catch (err) {
console.log(`${red('ERROR!')} During module creation: ${err}`);
const c = require('kleur');
const figures = require('./figures');
// rendering user input.
const styles = Object.freeze({
password: { scale: 1, render: input => '*'.repeat(input.length) },
emoji: { scale: 2, render: input => '😃'.repeat(input.length) },
invisible: { scale: 0, render: input => '' },
default: { scale: 1, render: input => `${input}` }
});
const render = type => styles[type] || styles.default;
// icon to signalize a prompt.
const symbols = Object.freeze({
aborted: c.red(figures.cross),
done: c.green(figures.tick),
default: c.cyan('?')
});
const symbol = (done, aborted) =>
aborted ? symbols.aborted : done ? symbols.done : symbols.default;
// between the question and the user's input.
const delimiter = completing =>
c.gray(completing ? figures.ellipsis : figures.pointerSmall);
const item = (expandable, expanded) =>
c.gray(expandable ? (expanded ? figures.pointerSmall : '+') : figures.line);
module.exports = {
styles,
render,
groupCommands.forEach(({ commandName, description }) => {
console.log(` ${green(padRight(commandName, maxWidth, ' '))} ${dim(description)}`)
})
})
function report(arr, testname) {
let i=0, len=arr.length;
const fastest = arr.reduce((a,b) => a.ms <= b.ms ? a : b);
arr = arr.map(o => ({ name:o.name, ms:toNum(o.ms)+'ms', ops:o.ops+' op/s' }));
const max = { ms:maxlen(arr, 'ms'), name:maxlen(arr, 'name'), ops:maxlen(arr, 'ops') };
console.log(testname);
for (; i < len; i++) {
console.log(` ${ rpad(arr[i].name, max.name, ' ') } ⇝ ${ lpad(arr[i].ms, max.ms, ' ') } @ ${ lpad(arr[i].ops, max.ops, ' ') }`);
}
console.log(colors.blue('\n ➤ ') + 'Fastest is: ' + colors.green(fastest.name) + '!\n\n');
}
spinner.stopAndPersist();
await install(target, isYarn);
}
spinner.succeed('Done!\n');
if (argv.git) {
await initGit(target);
}
let pfx = isYarn ? 'yarn' : 'npm run';
return (
trim(`
To get started, cd into the new directory:
${green('cd ' + dest)}
To start a development live-reload server:
${green(pfx + ' start')}
To create a production build (in ./build):
${green(pfx + ' build')}
To start a production HTTP/2 server:
${green(pfx + ' serve')}
`) + '\n'
);
};
function updateVSCodeDir() {
const libPackagePathDir = resolve(PACKAGE_ROOT, '.vscode')
const cpDirs = ['.vscode']
const cpItems = [...cpDirs.map((path) => `${join(ROOT, path)}/*`)]
sh.cp('-Rf', cpItems, `${libPackagePathDir}/`)
log(kleur.green('==.vscode updated ✅ ==\n'))
}
readFileSync(libPackageConfigPath, { encoding: 'utf-8' })
)
const newConfig = {
...libConfig,
compilerOptions: {
...libConfig.compilerOptions,
...starterConfig.compilerOptions,
},
include: [...new Set([...libConfig.include, ...starterConfig.include])],
}
const updatedLibTsConfigToWrite = JSON.stringify(newConfig, null, 2)
writeFileSync(libPackageConfigPath, updatedLibTsConfigToWrite)
log(kleur.green('==TS-Config:updated ☕️ ✅ ==\n'))
}
function writePackage(pkg) {
const updatedLibPkgToWrite = JSON.stringify(pkg, null, 2)
writeFileSync(join(PACKAGE_ROOT, 'package.json'), updatedLibPkgToWrite)
log(
'\n' +
kleur.green('updated package.json:') +
'\n' +
updatedLibPkgToWrite +
'\n' +
kleur.gray('========================\n')
)
}
}
switch (paramType) {
case 'array':
case 'object':
val = this.start(param, `${tab}${this.spaces}`);
break;
case 'boolean':
val = param ? `boolean ${cyan('true')}` : `boolean ${cyan('false')}`;
break;
case 'string':
val = `string ${red(`"${param}"`)} (length=${param.length})`;
break;
case 'null':
val = `${blue('null')}`;
break;
case 'number':
val = Number.isInteger(param) ? `int ${green(param)}` : `float ${yellow(param)}`;
break;
case 'function':
val = 'function () {}';
break;
case 'regexp':
val = `${blue(param)}`;
break;
default:
val = param;
break;
}
dump += this.makeArrowString(paramType, tab, key, val);
}
}