@@ -19,7 +19,7 @@ const isWebpack5 = version.startsWith('5');
1919 * @param {Boolean } setOutput Boolean that decides if a default output path will be set or not
2020 * @returns {Object } The webpack output or Promise when nodeOptions are present
2121 */
22- function run ( testCase , args = [ ] , setOutput = true , nodeArgs = [ ] , env ) {
22+ const run = ( testCase , args = [ ] , setOutput = true , nodeArgs = [ ] , env ) => {
2323 const cwd = path . resolve ( testCase ) ;
2424
2525 const outputPath = path . resolve ( testCase , 'bin' ) ;
@@ -34,9 +34,9 @@ function run(testCase, args = [], setOutput = true, nodeArgs = [], env) {
3434 } ) ;
3535
3636 return result ;
37- }
37+ } ;
3838
39- function runWatch ( { testCase, args = [ ] , setOutput = true , outputKillStr = 'Time' } ) {
39+ const runWatch = ( { testCase, args = [ ] , setOutput = true , outputKillStr = 'Time' } ) => {
4040 const cwd = path . resolve ( testCase ) ;
4141
4242 const outputPath = path . resolve ( testCase , 'bin' ) ;
@@ -70,9 +70,9 @@ function runWatch({ testCase, args = [], setOutput = true, outputKillStr = 'Time
7070 reject ( error ) ;
7171 } ) ;
7272 } ) ;
73- }
73+ } ;
7474
75- function runAndGetWatchProc ( testCase , args = [ ] , setOutput = true , input = '' , forcePipe = false ) {
75+ const runAndGetWatchProc = ( testCase , args = [ ] , setOutput = true , input = '' , forcePipe = false ) => {
7676 const cwd = path . resolve ( testCase ) ;
7777
7878 const outputPath = path . resolve ( testCase , 'bin' ) ;
@@ -92,7 +92,7 @@ function runAndGetWatchProc(testCase, args = [], setOutput = true, input = '', f
9292 const webpackProc = execa ( WEBPACK_PATH , argsWithOutput , options ) ;
9393
9494 return webpackProc ;
95- }
95+ } ;
9696/**
9797 * runPromptWithAnswers
9898 * @param {string } location location of current working directory
@@ -186,14 +186,14 @@ const runPromptWithAnswers = (location, args, answers, waitForOutput = true) =>
186186 * @returns {undefined }
187187 * @throws - throw an Error if file does not exist
188188 */
189- function appendDataIfFileExists ( testCase , file , data ) {
189+ const appendDataIfFileExists = ( testCase , file , data ) => {
190190 const filePath = path . resolve ( testCase , file ) ;
191191 if ( fs . existsSync ( filePath ) ) {
192192 fs . appendFileSync ( filePath , data ) ;
193193 } else {
194194 throw new Error ( `Oops! ${ filePath } does not exist!` ) ;
195195 }
196- }
196+ } ;
197197
198198/**
199199 * fs.copyFileSync was added in Added in: v8.5.0
@@ -203,7 +203,7 @@ function appendDataIfFileExists(testCase, file, data) {
203203 * @returns {String } - absolute file path of new file
204204 * @throws - throw an Error if file copy fails
205205 */
206- async function copyFileAsync ( testCase , file ) {
206+ const copyFileAsync = async ( testCase , file ) => {
207207 const fileToChangePath = path . resolve ( testCase , file ) ;
208208 const fileMetaData = path . parse ( file ) ;
209209 const fileCopyName = fileMetaData . name . concat ( '_copy' ) . concat ( fileMetaData . ext ) ;
@@ -214,35 +214,13 @@ async function copyFileAsync(testCase, file) {
214214 const data = fs . readFileSync ( fileToChangePath ) ;
215215 fs . writeFileSync ( copyFilePath , data ) ;
216216 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+ } ;
240218
241- async function runInstall ( cwd ) {
219+ const runInstall = async ( cwd ) => {
242220 await execa ( 'yarn' , {
243221 cwd,
244222 } ) ;
245- }
223+ } ;
246224
247225const runServe = ( args , testPath ) => {
248226 return runWatch ( {
@@ -273,7 +251,6 @@ module.exports = {
273251 runAndGetWatchProc,
274252 runPromptWithAnswers,
275253 appendDataIfFileExists,
276- copyFile,
277254 copyFileAsync,
278255 runInstall,
279256 runInfo,
0 commit comments