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


TypeScript ora.promise函數代碼示例

本文整理匯總了TypeScript中ora.promise函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript promise函數的具體用法?TypeScript promise怎麽用?TypeScript promise使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了promise函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: run

export const CleanCommand: Command = {
  name: 'clean',
  description:
    'Remove the node_modules and target directories from all projects.',

  async run(projects, projectGraph, { rootPath }) {
    const directoriesToDelete = [];
    for (const project of projects.values()) {
      if (await isDirectory(project.nodeModulesLocation)) {
        directoriesToDelete.push(project.nodeModulesLocation);
      }

      if (await isDirectory(project.targetLocation)) {
        directoriesToDelete.push(project.targetLocation);
      }
    }

    if (directoriesToDelete.length === 0) {
      console.log(chalk.bold.green('\n\nNo directories to delete'));
    } else {
      console.log(chalk.bold.red('\n\nDeleting directories:\n'));

      for (const dir of directoriesToDelete) {
        const deleting = del(dir, { force: true });
        ora.promise(deleting, relative(rootPath, dir));
        await deleting;
      }
    }
  },
};
開發者ID:cccnam5158,項目名稱:kibana,代碼行數:30,代碼來源:clean.ts

示例2: del

    }

    if (toDelete.length === 0) {
      log.write(chalk.bold.green('\n\nNothing to delete'));
    } else {
      log.write(chalk.bold.red('\n\nDeleting:\n'));

      /**
       * In order to avoid patterns like `/build` in packages from accidentally
       * impacting files outside the package we use `process.chdir()` to change
       * the cwd to the package and execute `del()` without the `force` option
       * so it will check that each file being deleted is within the package.
       *
       * `del()` does support a `cwd` option, but it's only for resolving the
       * patterns and does not impact the cwd check.
       */
      const originalCwd = process.cwd();
      try {
        for (const { pattern, cwd } of toDelete) {
          process.chdir(cwd);
          const promise = del(pattern);
          ora.promise(promise, relative(originalCwd, join(cwd, String(pattern))));
          await promise;
        }
      } finally {
        process.chdir(originalCwd);
      }
    }
  },
};
開發者ID:austec-automation,項目名稱:kibana,代碼行數:30,代碼來源:clean.ts


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