refactor: async/await cleanup (#2088)
Co-authored-by: Patryk Kuniczak <p.kuniczak@gmail.com>
This commit is contained in:
@@ -189,9 +189,9 @@ export class TestProject {
|
||||
return fs.pathExists(this.resolvePath(...path));
|
||||
}
|
||||
|
||||
async getOutputManifest(
|
||||
getOutputManifest(
|
||||
path: string = '.output/chrome-mv3/manifest.json',
|
||||
): Promise<any> {
|
||||
return await fs.readJson(this.resolvePath(path));
|
||||
return fs.readJson(this.resolvePath(path));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,7 +453,7 @@ async function moveHtmlFiles(
|
||||
);
|
||||
|
||||
// TODO: Optimize and only delete old path directories
|
||||
removeEmptyDirs(config.outDir);
|
||||
await removeEmptyDirs(config.outDir);
|
||||
|
||||
return movedChunks;
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@ export function download(config: ResolvedConfig): Plugin {
|
||||
resolveId(id) {
|
||||
if (id.startsWith('url:')) return '\0' + id;
|
||||
},
|
||||
async load(id) {
|
||||
load(id) {
|
||||
if (!id.startsWith('\0url:')) return;
|
||||
|
||||
// Load file from network or cache
|
||||
const url = id.replace('\0url:', '');
|
||||
return await fetchCached(url, config);
|
||||
return fetchCached(url, config);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ export function createWebExtRunner(): ExtensionRunner {
|
||||
},
|
||||
|
||||
async closeBrowser() {
|
||||
return await runner?.exit();
|
||||
await runner?.exit();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -184,8 +184,7 @@ async function importEntrypoints(infos: EntrypointInfo[]) {
|
||||
await Promise.all([
|
||||
// HTML
|
||||
...htmlInfos.map(async (info) => {
|
||||
const res = await importHtmlEntrypoint(info);
|
||||
resMap[info.inputPath] = res;
|
||||
resMap[info.inputPath] = await importHtmlEntrypoint(info);
|
||||
}),
|
||||
// JS
|
||||
(async () => {
|
||||
|
||||
@@ -87,7 +87,7 @@ export async function internalBuild(): Promise<BuildOutput> {
|
||||
} else {
|
||||
wxt.logger.info(`Opening ${pc.yellow(statsPath)} in browser...`);
|
||||
const { default: open } = await import('open');
|
||||
open(wxt.config.analysis.outputFile);
|
||||
await open(wxt.config.analysis.outputFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,7 @@ import { withTimeout } from './time';
|
||||
|
||||
function isOffline(): Promise<boolean> {
|
||||
const isOffline = new Promise<boolean>((res) => {
|
||||
dns.resolve('google.com', (err) => {
|
||||
if (err == null) {
|
||||
res(false);
|
||||
} else {
|
||||
res(true);
|
||||
}
|
||||
});
|
||||
dns.resolve('google.com', (err) => res(err != null));
|
||||
});
|
||||
return withTimeout(isOffline, 1e3).catch(() => true);
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ function autoMountUi(
|
||||
}
|
||||
}
|
||||
}
|
||||
observeElement(resolvedAnchor);
|
||||
void observeElement(resolvedAnchor);
|
||||
|
||||
return { stopAutoMount: _stopAutoMount };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user