Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exit(message) {
if (message && !argv['completion-logic']) {
const { terminal } = require('@absolunet/terminal');
terminal.exit(message);
} else {
process.exit(); // eslint-disable-line no-process-exit, unicorn/no-process-exit
}
}
if (scopedMatch !== null) {
normalizedName = `${scopedMatch[1]}${prefix}${scopedMatch[2]}`;
} else {
const namedMatch = (/^[a-z0-9-]+$/u).exec(name);
if (namedMatch !== null) {
normalizedName = `${prefix}${name}`;
} else {
normalizedName = name;
}
}
let extension;
try {
extension = require(normalizedName); // eslint-disable-line global-require
} catch (error) {
terminal.exit(`Extension '${name}' not found`);
}
extension.init({ options: CONFIG.extensions[name].options });
enabled[extension.id] = extension;
}
});
error(error) {
terminal.error(`[nwayo-extension:${this.id} error]`);
terminal.echo(error);
terminal.exit();
}
runWorkflowTask(task, { bundle }) {
let taskFile;
let extension;
const [, extensionName, taskName] = (/^(?[a-z-]+):(?[a-z-]+)$/u).exec(task) || [];
if (extensionName) {
extension = env.extensions[extensionName];
if (!env.extensions[extensionName]) {
terminal.exit(`Extension ${chalk.underline(extensionName)} is not enabled`);
}
if (!env.extensions[extensionName].taskExists(taskName)) {
terminal.exit(`Task ${chalk.underline(task)} does not exists`);
}
} else {
const [group] = task.split('-');
taskFile = `${paths.workflow.tasks}/${group}`;
if (!fss.exists(`${taskFile}.js`)) {
terminal.exit(`Task ${chalk.underline(task)} does not exists`);
}
}
//-- Boost max listeners
events.EventEmitter.prototype._maxListeners = 100;
return plumber((error) => {
terminal.spacer(2);
terminal.echo(`${emoji.get('monkey')} ${error.toString()}`);
terminal.exit();
});
}
const subBundleData = fss.readYaml(subBundleFile);
if (subBundleData.assets && subBundleData.assets.components) {
data[name].assets.components = [...new Set([...data[name].assets.components, ...subBundleData.assets.components])];
}
if (subBundleData.scripts && subBundleData.scripts.collections) {
Object.assign(data[name].scripts.collections, subBundleData.scripts.collections);
}
if (subBundleData.styles && subBundleData.styles.collections) {
Object.assign(data[name].styles.collections, subBundleData.styles.collections);
}
}
} else if (requiredSubname !== '*') {
terminal.exit(`Bundle ${chalk.underline(bundle)} does not exists`);
}
}
} else {
terminal.exit(`${requiredName !== '*' ? `Bundle ${chalk.underline(bundle)} does not exists` : `No bundle found`}`);
}
__.bundles = data;
__.bundlesComponents = uniq(flatten(map(__.bundles, property('assets.components'))));
}
terminal.echo(boxen(
`Workflow update available ${chalk.dim(installedVersion)} ${chalk.reset('→')} ${chalk.green(requiredVersion)}
The required version in your project's package.json
is greater than the installed one
Run ${chalk.cyan('nwayo install workflow')} to update`,
{
padding: 1,
margin: 0.5,
align: 'center',
borderColor: 'yellow'
}
));
terminal.exit();
}
}
cli(meowCli) {
if (__(this).get('deprecated')) {
terminal.spacer();
terminal.warning(`DEPRECATED - ${__(this).get('deprecated')}`);
terminal.exit();
}
throw new Error('Not overwritten by subclass');
}