This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-cli/src/util.ts
2021-02-05 19:58:05 +08:00

35 lines
882 B
TypeScript

import globLib, { IOptions } from "glob";
export async function delay(timeout: number) {
return new Promise((resolve) => {
setTimeout(() => {
resolve('');
}, timeout);
});
}
export function getAssetsDir() {
return `${__dirname}/../assets`;
}
export async function glob(pattern: string, options?: IOptions) {
return new Promise((resolve, reject) => {
if (options) {
globLib(pattern, options, (err, ret) => {
if (err) {
reject(err);
} else {
resolve(ret);
}
});
} else {
globLib(pattern, (err, ret) => {
if (err) {
reject(err);
} else {
resolve(ret);
}
});
}
}) as Promise<string[]>;
}