|
1 |
| -import * as fs from 'fs' |
2 |
| -import * as path from 'path' |
3 |
| -import { fileURLToPath } from 'url' |
| 1 | +import * as fs from 'node:fs' |
| 2 | +import * as path from 'node:path' |
| 3 | +import { fileURLToPath } from 'node:url' |
4 | 4 |
|
5 | 5 | const directoryName = path.dirname(fileURLToPath(import.meta.url))
|
6 | 6 | const inputPath = path.resolve(directoryName, '..', '..', 'graphiql', 'dist')
|
7 | 7 | const jsFile = path.resolve(inputPath, 'yoga-graphiql.umd.js')
|
8 | 8 | const cssFile = path.resolve(inputPath, 'style.css')
|
| 9 | +const faviconFile = path.resolve( |
| 10 | + directoryName, |
| 11 | + '../../../website/public/favicon.ico', |
| 12 | +) |
9 | 13 |
|
10 | 14 | const outFile = path.resolve(directoryName, '..', 'src', 'graphiql.ts')
|
11 | 15 |
|
12 |
| -const jsContents = fs.readFileSync(jsFile, 'utf-8') |
13 |
| -const cssContents = fs.readFileSync(cssFile, 'utf-8') |
| 16 | +const [jsContents, cssContents, faviconContents] = await Promise.all([ |
| 17 | + fs.promises.readFile(jsFile, 'utf-8'), |
| 18 | + fs.promises.readFile(cssFile, 'utf-8'), |
| 19 | + fs.promises.readFile(faviconFile, 'base64'), |
| 20 | +]) |
14 | 21 |
|
15 |
| -fs.writeFileSync( |
| 22 | +await fs.promises.writeFile( |
16 | 23 | outFile,
|
17 | 24 | [
|
18 | 25 | `export const js: string = ${JSON.stringify(jsContents)}`,
|
19 | 26 | `export const css: string = ${JSON.stringify(cssContents)}`,
|
| 27 | + `export const favicon: string = ${JSON.stringify( |
| 28 | + `data:image/x-icon;base64,${faviconContents}`, |
| 29 | + )}`, |
20 | 30 | ].join('\n'),
|
21 | 31 | )
|
0 commit comments