aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/gen-webext-polyfill.ts
blob: 5c09e07f8aac2e289af6ca2f8036df481776c77b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import fs from 'node:fs/promises';
const files = {} as Record<string, string>
const promises = [] as Promise<void>[]
for (const f of await fs.readdir('node_modules/@types/webextension-polyfill', {
  recursive: true,
}))
  promises.push((async () => {
    const fp = 'node_modules/@types/webextension-polyfill/' + f;
    const stat = await fs.stat(fp)
    if (!stat.isDirectory())
      files[fp] = await fs.readFile(fp, 'utf-8')
  })())
await Promise.all(promises)
await fs.writeFile('src/lib/webext-polyfill.ts', `export const files = ${JSON.stringify(files, null, 2)};
export default files;`)