本文整理汇总了TypeScript中@angular-devkit/schematics/tools.NodeWorkflow.execute方法的典型用法代码示例。如果您正苦于以下问题:TypeScript NodeWorkflow.execute方法的具体用法?TypeScript NodeWorkflow.execute怎么用?TypeScript NodeWorkflow.execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular-devkit/schematics/tools.NodeWorkflow
的用法示例。
在下文中一共展示了NodeWorkflow.execute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: xit
xit('works', done => {
const workflow = new NodeWorkflow(new NodeJsSyncHost(), { dryRun: true });
const collection = path.join(__dirname, '../../../../schematics/angular/package.json');
workflow.execute({
collection,
schematic: 'ng-new',
options: { name: 'workflow-test', version: '6.0.0-rc.4' },
}).toPromise().then(done, done.fail);
});
示例2: main
//.........这里部分代码省略.........
${terminal.white('UPDATE')} ${event.path} (${event.content.length} bytes)
`);
break;
case 'create':
loggingQueue.push(tags.oneLine`
${terminal.green('CREATE')} ${event.path} (${event.content.length} bytes)
`);
break;
case 'delete':
loggingQueue.push(`${terminal.yellow('DELETE')} ${event.path}`);
break;
case 'rename':
loggingQueue.push(`${terminal.blue('RENAME')} ${event.path} => ${event.to}`);
break;
}
});
/**
* Listen to lifecycle events of the workflow to flush the logs between each phases.
*/
workflow.lifeCycle.subscribe(event => {
if (event.kind == 'workflow-end' || event.kind == 'post-tasks-start') {
if (!error) {
// Flush the log queue and clean the error state.
loggingQueue.forEach(log => logger.info(log));
}
loggingQueue = [];
error = false;
}
});
/**
* Remove every options from argv that we support in schematics itself.
*/
const parsedArgs = Object.assign({}, argv);
delete parsedArgs['--'];
for (const key of booleanArgs) {
delete parsedArgs[key];
}
/**
* Add options from `--` to args.
*/
const argv2 = minimist(argv['--']);
for (const key of Object.keys(argv2)) {
parsedArgs[key] = argv2[key];
}
// Pass the rest of the arguments as the smart default "argv". Then delete it.
workflow.registry.addSmartDefaultProvider('argv', (schema: JsonObject) => {
if ('index' in schema) {
return argv._[Number(schema['index'])];
} else {
return argv._;
}
});
delete parsedArgs._;
/**
* Execute the workflow, which will report the dry run events, run the tasks, and complete
* after all is done.
*
* The Observable returned will properly cancel the workflow if unsubscribed, error out if ANY
* step of the workflow failed (sink or task), with details included, and will only complete
* when everything is done.
*/
try {
await workflow.execute({
collection: collectionName,
schematic: schematicName,
options: parsedArgs,
allowPrivate: allowPrivate,
debug: debug,
logger: logger,
})
.toPromise();
if (nothingDone) {
logger.info('Nothing to be done.');
}
return 0;
} catch (err) {
if (err instanceof UnsuccessfulWorkflowExecution) {
// "See above" because we already printed the error.
logger.fatal('The Schematic workflow failed. See above.');
} else if (debug) {
logger.fatal('An error occured:\n' + err.stack);
} else {
logger.fatal(err.stack || err.message);
}
return 1;
}
}
示例3: error
});
delete args._;
/**
* Execute the workflow, which will report the dry run events, run the tasks, and complete
* after all is done.
*
* The Observable returned will properly cancel the workflow if unsubscribed, error out if ANY
* step of the workflow failed (sink or task), with details included, and will only complete
* when everything is done.
*/
workflow.execute({
collection: collectionName,
schematic: schematicName,
options: args,
allowPrivate: allowPrivate,
debug: debug,
logger: logger,
})
.subscribe({
error(err: Error) {
// In case the workflow was not successful, show an appropriate error message.
if (err instanceof UnsuccessfulWorkflowExecution) {
// "See above" because we already printed the error.
logger.fatal('The Schematic workflow failed. See above.');
} else if (debug) {
logger.fatal('An error occured:\n' + err.stack);
} else {
logger.fatal(err.stack || err.message);
}