11import fs from 'fs-extra' ;
2- import chalk from 'chalk' ;
32import path from 'path' ;
4- import logSymbols from 'log-symbols' ;
53
64import { CONFIG , EXT } from '../constants' ;
5+ import { Logger } from './Logger' ;
76
87export class FileService {
98 constructor ( fileName ) {
@@ -25,38 +24,29 @@ export class FileService {
2524 const filePath = this . getFilePath ( EXT . component ) ;
2625 if ( ! fs . pathExistsSync ( filePath ) ) {
2726 fs . writeFileSync ( filePath , template ) ;
28- console . log (
29- logSymbols . success ,
30- chalk . green ( `Successfully generated component file ${ chalk . white ( filePath ) } ` )
31- ) ;
27+ Logger . success ( chalk => `Successfully generated component file ${ chalk . white ( filePath ) } ` ) ;
3228 } else {
33- console . log ( logSymbols . warning , chalk . yellow ( `File already exists ${ chalk . white ( filePath ) } ` ) ) ;
29+ Logger . warn ( chalk => `File already exists ${ chalk . white ( filePath ) } ` ) ;
3430 }
3531 }
3632
3733 genStyle ( template ) {
3834 const filePath = this . getFilePath ( EXT . style , 'style' ) ;
3935 if ( ! fs . pathExistsSync ( filePath ) ) {
4036 fs . writeFileSync ( filePath , template ) ;
41- console . log (
42- logSymbols . success ,
43- chalk . green ( `Successfully generated style file ${ chalk . white ( filePath ) } ` )
44- ) ;
37+ Logger . success ( chalk => `Successfully generated style file ${ chalk . white ( filePath ) } ` ) ;
4538 } else {
46- console . log ( logSymbols . warning , chalk . yellow ( `File already exists ${ chalk . white ( filePath ) } ` ) ) ;
39+ Logger . warn ( chalk => `File already exists ${ chalk . white ( filePath ) } ` ) ;
4740 }
4841 }
4942
5043 genTest ( template ) {
5144 const filePath = this . getFilePath ( EXT . component , 'test' ) ;
5245 if ( ! fs . pathExistsSync ( filePath ) ) {
5346 fs . writeFileSync ( filePath , template ) ;
54- console . log (
55- logSymbols . success ,
56- chalk . green ( `Successfully generated test file ${ chalk . white ( filePath ) } ` )
57- ) ;
47+ Logger . success ( chalk => `Successfully generated test file ${ chalk . white ( filePath ) } ` ) ;
5848 } else {
59- console . log ( logSymbols . warning , chalk . yellow ( `File already exists ${ chalk . white ( filePath ) } ` ) ) ;
49+ Logger . warn ( chalk => `File already exists ${ chalk . white ( filePath ) } ` ) ;
6050 }
6151 }
6252}
0 commit comments