本文整理匯總了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;
}
}
},
};
示例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);
}
}
},
};