當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript NodeWorkflow.execute方法代碼示例

本文整理匯總了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);
  });
開發者ID:DevIntent,項目名稱:angular-cli,代碼行數:10,代碼來源:node-workflow_spec.ts

示例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;
  }
}
開發者ID:cexbrayat,項目名稱:angular-cli,代碼行數:101,代碼來源:schematics.ts

示例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);
    }
開發者ID:fmalcher,項目名稱:angular-cli,代碼行數:31,代碼來源:schematics.ts


注:本文中的@angular-devkit/schematics/tools.NodeWorkflow.execute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。