@@ -19,7 +19,7 @@ const isWebpack5 = version.startsWith('5');
19
19
* @param {Boolean } setOutput Boolean that decides if a default output path will be set or not
20
20
* @returns {Object } The webpack output or Promise when nodeOptions are present
21
21
*/
22
- function run ( testCase , args = [ ] , setOutput = true , nodeArgs = [ ] , env ) {
22
+ const run = ( testCase , args = [ ] , setOutput = true , nodeArgs = [ ] , env ) => {
23
23
const cwd = path . resolve ( testCase ) ;
24
24
25
25
const outputPath = path . resolve ( testCase , 'bin' ) ;
@@ -34,9 +34,9 @@ function run(testCase, args = [], setOutput = true, nodeArgs = [], env) {
34
34
} ) ;
35
35
36
36
return result ;
37
- }
37
+ } ;
38
38
39
- function runWatch ( { testCase, args = [ ] , setOutput = true , outputKillStr = 'Time' } ) {
39
+ const runWatch = ( { testCase, args = [ ] , setOutput = true , outputKillStr = 'Time' } ) => {
40
40
const cwd = path . resolve ( testCase ) ;
41
41
42
42
const outputPath = path . resolve ( testCase , 'bin' ) ;
@@ -70,9 +70,9 @@ function runWatch({ testCase, args = [], setOutput = true, outputKillStr = 'Time
70
70
reject ( error ) ;
71
71
} ) ;
72
72
} ) ;
73
- }
73
+ } ;
74
74
75
- function runAndGetWatchProc ( testCase , args = [ ] , setOutput = true , input = '' , forcePipe = false ) {
75
+ const runAndGetWatchProc = ( testCase , args = [ ] , setOutput = true , input = '' , forcePipe = false ) => {
76
76
const cwd = path . resolve ( testCase ) ;
77
77
78
78
const outputPath = path . resolve ( testCase , 'bin' ) ;
@@ -92,7 +92,7 @@ function runAndGetWatchProc(testCase, args = [], setOutput = true, input = '', f
92
92
const webpackProc = execa ( WEBPACK_PATH , argsWithOutput , options ) ;
93
93
94
94
return webpackProc ;
95
- }
95
+ } ;
96
96
/**
97
97
* runPromptWithAnswers
98
98
* @param {string } location location of current working directory
@@ -186,14 +186,14 @@ const runPromptWithAnswers = (location, args, answers, waitForOutput = true) =>
186
186
* @returns {undefined }
187
187
* @throws - throw an Error if file does not exist
188
188
*/
189
- function appendDataIfFileExists ( testCase , file , data ) {
189
+ const appendDataIfFileExists = ( testCase , file , data ) => {
190
190
const filePath = path . resolve ( testCase , file ) ;
191
191
if ( fs . existsSync ( filePath ) ) {
192
192
fs . appendFileSync ( filePath , data ) ;
193
193
} else {
194
194
throw new Error ( `Oops! ${ filePath } does not exist!` ) ;
195
195
}
196
- }
196
+ } ;
197
197
198
198
/**
199
199
* fs.copyFileSync was added in Added in: v8.5.0
@@ -203,7 +203,7 @@ function appendDataIfFileExists(testCase, file, data) {
203
203
* @returns {String } - absolute file path of new file
204
204
* @throws - throw an Error if file copy fails
205
205
*/
206
- async function copyFileAsync ( testCase , file ) {
206
+ const copyFileAsync = async ( testCase , file ) => {
207
207
const fileToChangePath = path . resolve ( testCase , file ) ;
208
208
const fileMetaData = path . parse ( file ) ;
209
209
const fileCopyName = fileMetaData . name . concat ( '_copy' ) . concat ( fileMetaData . ext ) ;
@@ -214,35 +214,13 @@ async function copyFileAsync(testCase, file) {
214
214
const data = fs . readFileSync ( fileToChangePath ) ;
215
215
fs . writeFileSync ( copyFilePath , data ) ;
216
216
return copyFilePath ;
217
- }
218
-
219
- /**
220
- * fs.copyFileSync was added in Added in: v8.5.0
221
- * We should refactor the below code once our minimal supported version is v8.5.0
222
- * @param {String } testCase - testCase directory
223
- * @param {String } file - file relative to testCase which is going to be copied
224
- * @returns {String } - absolute file path of new file
225
- * @throws - throw an Error if file copy fails
226
- */
227
- function copyFile ( testCase , file ) {
228
- const fileToChangePath = path . resolve ( testCase , file ) ;
229
- const fileMetaData = path . parse ( file ) ;
230
- const fileCopyName = fileMetaData . name . concat ( '_copy' ) . concat ( fileMetaData . ext ) ;
231
- const copyFilePath = path . resolve ( testCase , fileCopyName ) ;
232
- if ( fs . existsSync ( fileToChangePath ) ) {
233
- const fileData = fs . readFileSync ( fileToChangePath ) . toString ( ) ;
234
- fs . writeFileSync ( copyFilePath , fileData ) ;
235
- return copyFilePath ;
236
- } else {
237
- throw new Error ( `Oops! ${ fileToChangePath } does not exist!` ) ;
238
- }
239
- }
217
+ } ;
240
218
241
- async function runInstall ( cwd ) {
219
+ const runInstall = async ( cwd ) => {
242
220
await execa ( 'yarn' , {
243
221
cwd,
244
222
} ) ;
245
- }
223
+ } ;
246
224
247
225
const runServe = ( args , testPath ) => {
248
226
return runWatch ( {
@@ -273,7 +251,6 @@ module.exports = {
273
251
runAndGetWatchProc,
274
252
runPromptWithAnswers,
275
253
appendDataIfFileExists,
276
- copyFile,
277
254
copyFileAsync,
278
255
runInstall,
279
256
runInfo,
0 commit comments