@@ -60,10 +60,12 @@ const promises = fixtures.map((fixture) =>
60
60
} )
61
61
await Promise . all ( publishDirectories . map ( ( dir ) => rm ( dir , { recursive : true , force : true } ) ) )
62
62
63
- if ( NEXT_VERSION !== 'latest' ) {
64
- await setNextVersionInFixture ( cwd , NEXT_VERSION , {
65
- logPrefix : `[${ fixture } ] ` ,
66
- } )
63
+ const fixtureNextVersionSatisfied = await setNextVersionInFixture ( cwd , NEXT_VERSION , {
64
+ logPrefix : `[${ fixture } ] ` ,
65
+ } )
66
+
67
+ if ( ! fixtureNextVersionSatisfied ) {
68
+ return
67
69
}
68
70
69
71
let cmd = ``
@@ -79,19 +81,26 @@ const promises = fixtures.map((fixture) =>
79
81
await rm ( join ( cwd , 'package-lock.json' ) , { force : true } )
80
82
}
81
83
82
- const addPrefix = new Transform ( {
83
- transform ( chunk , encoding , callback ) {
84
- this . push ( chunk . toString ( ) . replace ( / \n / gm, `\n[${ fixture } ] ` ) )
85
- callback ( )
86
- } ,
87
- flush ( callback ) {
88
- // final transform might create non-terminated line with a prefix
89
- // so this is just to make sure we end with a newline so further writes
90
- // to same destination stream start on a new line for better readability
91
- this . push ( '\n' )
92
- callback ( )
93
- } ,
94
- } )
84
+ const addPrefix = ( ) => {
85
+ let isFirstChunk = true
86
+ return new Transform ( {
87
+ transform ( chunk , encoding , callback ) {
88
+ if ( isFirstChunk ) {
89
+ this . push ( `[${ fixture } ] ` )
90
+ isFirstChunk = false
91
+ }
92
+ this . push ( chunk . toString ( ) . replace ( / \n / gm, `\n[${ fixture } ] ` ) )
93
+ callback ( )
94
+ } ,
95
+ flush ( callback ) {
96
+ // final transform might create non-terminated line with a prefix
97
+ // so this is just to make sure we end with a newline so further writes
98
+ // to same destination stream start on a new line for better readability
99
+ this . push ( '\n' )
100
+ callback ( )
101
+ } ,
102
+ } )
103
+ }
95
104
96
105
console . log ( `[${ fixture } ] Running \`${ cmd } \`...` )
97
106
const output = execaCommand ( cmd , {
@@ -100,16 +109,24 @@ const promises = fixtures.map((fixture) =>
100
109
env : { ...process . env , FORCE_COLOR : '1' } ,
101
110
} )
102
111
if ( process . env . DEBUG ) {
103
- output . stdout ?. pipe ( addPrefix ) . pipe ( process . stdout )
112
+ output . stdout ?. pipe ( addPrefix ( ) ) . pipe ( process . stdout )
104
113
}
105
- output . stderr ?. pipe ( addPrefix ) . pipe ( process . stderr )
114
+ output . stderr ?. pipe ( addPrefix ( ) ) . pipe ( process . stderr )
106
115
return output . finally ( async ( ) => {
107
- if ( NEXT_VERSION !== 'latest' ) {
108
- await setNextVersionInFixture ( cwd , 'latest' , {
109
- logPrefix : `[${ fixture } ] ` ,
110
- operation : 'revert' ,
111
- } )
116
+ if ( process . env . DEBUG ) {
117
+ const npmListPromise = execaCommand (
118
+ packageManager ?. startsWith ( 'pnpm' ) ? 'pnpm list next' : 'npm list next' ,
119
+ { cwd, stdio : 'pipe' , reject : false } ,
120
+ )
121
+ npmListPromise . stdout ?. pipe ( addPrefix ( ) ) . pipe ( process . stdout )
122
+ npmListPromise . stderr ?. pipe ( addPrefix ( ) ) . pipe ( process . stderr )
123
+ await npmListPromise
112
124
}
125
+
126
+ await setNextVersionInFixture ( cwd , 'latest' , {
127
+ logPrefix : `[${ fixture } ] ` ,
128
+ operation : 'revert' ,
129
+ } )
113
130
if ( output . exitCode !== 0 ) {
114
131
const errorMessage = `[${ fixture } ] 🚨 Failed to install dependencies or build a fixture`
115
132
console . error ( errorMessage )
0 commit comments