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

35 lines
882 B
TypeScript
Raw Normal View History

2021-02-05 16:35:52 +08:00
import globLib, { IOptions } from "glob";
2021-02-05 18:20:42 +08:00
export async function delay(timeout: number) {
return new Promise((resolve) => {
setTimeout(() => {
resolve('');
}, timeout);
});
}
export function getAssetsDir() {
return `${__dirname}/../assets`;
2021-02-05 16:35:52 +08:00
}
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[]>;
}