@@ -16,14 +16,14 @@ import { existsAsync } from '../util/functions';
1616
1717// Custom messages
1818const STRINGS = {
19- CONFIG_EXISTS : 'ESLint config file already exists' ,
20- COPYING_CONFIG : 'Copying ESLint config file to ' ,
19+ CONFIG_EXISTS : 'Config file already exists' ,
20+ COPYING_CONFIG : 'Copying config files ' ,
2121} ;
2222
2323
2424// Custom error messages
2525const ERRORS = {
26- COPY_FAILED : 'Copying ESLint config file failed' ,
26+ COPY_FAILED : 'Copying config file failed' ,
2727} ;
2828
2929
@@ -33,27 +33,37 @@ const ERRORS = {
3333 * @param pluginProvider Plugin utilities provider
3434 */
3535async function taskFn ( done : any , { logger, paths, gulp } : any = { } ) : Promise < any > {
36- const configFilename = '.eslintrc' ;
36+ const configFilenames : string [ ] = [
37+ '.eslintrc' ,
38+ '.babelrc' ,
39+ ] ;
40+
3741 const templateDir : string = path . join ( paths . cwd , '/node_modules/@frontvue/plugin-js/template' ) ;
3842 const dest : string = path . join ( paths . cwd ) ;
3943
4044 // Perform a directory check to avoid overwriting existing files
41- let isCopied : boolean = false ;
45+ let areCopied : boolean [ ] = [ ] ;
4246 try {
43- isCopied = await existsAsync ( path . join ( dest , configFilename ) ) ;
47+ for ( const file of configFilenames ) {
48+ areCopied = [ ...areCopied , await existsAsync ( path . join ( dest , file ) ) ] ;
49+ }
4450 } catch ( error ) {
4551 return Promise . reject ( new Error ( `${ ERRORS . COPY_FAILED } ${ error . message } ` ) ) ;
4652 }
4753
4854 // If the config file are already copied, or folder already exists, exit
49- if ( isCopied ) {
55+ if ( areCopied . every ( item => item ) ) {
5056 logger . debug ( STRINGS . CONFIG_EXISTS ) ;
5157 return Promise . resolve ( ) ;
5258 }
5359
54- logger . debug ( `${ STRINGS . COPYING_CONFIG } ${ chalk . cyan . bold ( path . join ( dest , configFilename ) ) } ` ) ;
60+ const configSourcePaths = configFilenames . map ( filename => path . join ( templateDir , filename ) ) ;
61+
62+ logger . debug (
63+ `${ STRINGS . COPYING_CONFIG } ${ chalk . cyan . bold ( configFilenames . join ( ', ' ) ) } to ${ chalk . cyan . bold ( dest ) } ` ,
64+ ) ;
5565 return new Promise ( ( resolve , reject ) => {
56- gulp . src ( path . join ( templateDir , configFilename ) , { dot : true } )
66+ gulp . src ( configSourcePaths , { dot : true } )
5767 // Initialize gulp-plumber to prevent process termination in case of error
5868 . pipe ( plumber ( { errorHandler : error => logger . fatal ( error . message ) } ) )
5969 . on ( 'error' , ( error : any ) => {
0 commit comments