@@ -138,6 +138,12 @@ export const prepareNormalSetup = (fixtureName: string) => {
138
138
return startApp ;
139
139
} ;
140
140
141
+ const PACKAGE_INSTALL = {
142
+ npm : ( path : string ) => `npm add ${ path } ` ,
143
+ pnpm : ( path : string ) => `pnpm add ${ path } ` ,
144
+ yarn : ( path : string ) => `yarn add ${ path } ` ,
145
+ } as const ;
146
+
141
147
export const prepareStandaloneSetup = ( fixtureName : string ) => {
142
148
const wakuDir = fileURLToPath ( new URL ( '../packages/waku' , import . meta. url ) ) ;
143
149
const { version } = createRequire ( import . meta. url ) (
@@ -151,7 +157,11 @@ export const prepareStandaloneSetup = (fixtureName: string) => {
151
157
const tmpDir = process . env . TEMP_DIR || tmpdir ( ) ;
152
158
let standaloneDir : string | undefined ;
153
159
let built = false ;
154
- const startApp = async ( mode : 'DEV' | 'PRD' | 'STATIC' ) => {
160
+ const startApp = async (
161
+ mode : 'DEV' | 'PRD' | 'STATIC' ,
162
+ packageManager : 'npm' | 'pnpm' | 'yarn' = 'npm' ,
163
+ packageDir = '' ,
164
+ ) => {
155
165
if ( ! standaloneDir ) {
156
166
standaloneDir = mkdtempSync ( join ( tmpDir , fixtureName ) ) ;
157
167
cpSync ( fixtureDir , standaloneDir , {
@@ -164,16 +174,22 @@ export const prepareStandaloneSetup = (fixtureName: string) => {
164
174
cwd : wakuDir ,
165
175
stdio : 'inherit' ,
166
176
} ) ;
177
+ const wakuPackageTgz = join ( standaloneDir , `waku-${ version } .tgz` ) ;
178
+ const installScript = PACKAGE_INSTALL [ packageManager ] ( wakuPackageTgz ) ;
179
+ execSync ( installScript , { cwd : standaloneDir , stdio : 'inherit' } ) ;
167
180
execSync (
168
181
`npm install --force ${ join ( standaloneDir , `waku-${ version } .tgz` ) } ` ,
169
182
{ cwd : standaloneDir , stdio : 'inherit' } ,
170
183
) ;
171
184
}
172
185
if ( mode !== 'DEV' && ! built ) {
173
- rmSync ( `${ standaloneDir } /dist` , { recursive : true , force : true } ) ;
186
+ rmSync ( `${ join ( standaloneDir , packageDir , 'dist' ) } ` , {
187
+ recursive : true ,
188
+ force : true ,
189
+ } ) ;
174
190
execSync (
175
191
`node ${ join ( standaloneDir , './node_modules/waku/dist/cli.js' ) } build` ,
176
- { cwd : standaloneDir } ,
192
+ { cwd : join ( standaloneDir , packageDir ) } ,
177
193
) ;
178
194
built = true ;
179
195
}
@@ -190,7 +206,7 @@ export const prepareStandaloneSetup = (fixtureName: string) => {
190
206
cmd = `node ${ join ( standaloneDir , './node_modules/serve/build/main.js' ) } dist/public -p ${ port } ` ;
191
207
break ;
192
208
}
193
- const cp = exec ( cmd , { cwd : standaloneDir } ) ;
209
+ const cp = exec ( cmd , { cwd : join ( standaloneDir , packageDir ) } ) ;
194
210
debugChildProcess ( cp , fileURLToPath ( import . meta. url ) , [
195
211
/ E x p e r i m e n t a l W a r n i n g : C u s t o m E S M L o a d e r s i s a n e x p e r i m e n t a l f e a t u r e a n d m i g h t c h a n g e a t a n y t i m e / ,
196
212
] ) ;
0 commit comments