Refactor: make Node.js run compatible

This commit is contained in:
SukkaW
2024-07-23 17:42:10 +08:00
parent 1f42c27afe
commit 553dd62eb1
32 changed files with 163 additions and 136 deletions

View File

@@ -13,9 +13,9 @@ const ASSETS_LIST = {
'amazon-adsystem-com_amazon-apstag.js': 'https://raw.githubusercontent.com/AdguardTeam/Scriptlets/master/dist/redirect-files/amazon-apstag.js'
} as const;
const mockDir = path.resolve(import.meta.dir, '../Mock');
const mockDir = path.resolve(__dirname, '../Mock');
export const downloadMockAssets = task(import.meta.main, import.meta.path)((span) => Promise.all(Object.entries(ASSETS_LIST).map(
export const downloadMockAssets = task(typeof Bun !== 'undefined' ? Bun.main === __filename : require.main === module, __filename)((span) => Promise.all(Object.entries(ASSETS_LIST).map(
([filename, url]) => span
.traceChild(url)
.traceAsyncFn(() => fetchWithRetry(url).then(res => {