File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
packages/playground/cli/src/lib/blueprints-v2 Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments