Skip to content

Commit 83ca72b

Browse files
committed
Correct merge conflicts
2 parents e3b286b + d6974ee commit 83ca72b

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
export async function getV2Runner(): Promise<File> {
2+
let data = null;
3+
4+
/**
5+
* Avoid a static dependency for now.
6+
*
7+
* Playground.wordpress.net does not need to know about the new runner yet, and
8+
* a static import would force it to download the v2 runner even when it's not needed.
9+
* This breaks the offline mode as the static assets list is not yet updated to accommodate
10+
* for the new .phar file.
11+
*/
12+
// @ts-ignore
13+
const v2_runner_url = (await import('../../../public/blueprints.phar?url'))
14+
.default;
15+
16+
/**
17+
* Only load the v2 runner via node:fs when running in Node.js.
18+
*/
19+
if (typeof process !== 'undefined' && process.versions?.node) {
20+
let path = v2_runner_url;
21+
if (path.startsWith('/@fs/')) {
22+
path = path.slice('/@fs'.length);
23+
}
24+
if (path.startsWith('file://')) {
25+
path = path.slice('file://'.length);
26+
}
27+
28+
const { readFile } = await import('node:fs/promises');
29+
data = await readFile(path);
30+
} else {
31+
const response = await fetch(v2_runner_url);
32+
data = await response.blob();
33+
}
34+
return new File([data], `blueprints.phar`, {
35+
type: 'application/zip',
36+
});
37+
}

0 commit comments

Comments
 (0)