11import fs from 'fs-extra' ;
22import path from 'path' ;
33
4- import { CONFIG , EXT , APP_ROOT } from '../constants' ;
4+ import { APP_ROOT } from '@/constants' ;
5+ import { config } from '@/config' ;
56import { Logger } from './Logger' ;
67
78export class FileService {
8- private dirPath = path . resolve ( CONFIG . path , CONFIG . wrapFolder ? this . fileName : '' ) ;
9+ private dirPath = path . resolve ( config . path , config . wrapFolder ? this . fileName : '' ) ;
910
1011 constructor ( private fileName : string ) { }
1112
@@ -19,7 +20,7 @@ export class FileService {
1920 }
2021
2122 genJs ( template : string ) {
22- const filePath = this . getFilePath ( EXT . component ) ;
23+ const filePath = this . getFilePath ( config . ext . component ) ;
2324 if ( ! fs . pathExistsSync ( filePath ) ) {
2425 fs . writeFileSync ( filePath , template ) ;
2526 Logger . success (
@@ -32,7 +33,7 @@ export class FileService {
3233 }
3334
3435 genStyle ( template : string ) {
35- const filePath = this . getFilePath ( EXT . style , 'styles' ) ;
36+ const filePath = this . getFilePath ( config . ext . style , config . prefixes . style ) ;
3637 if ( ! fs . pathExistsSync ( filePath ) ) {
3738 fs . writeFileSync ( filePath , template ) ;
3839 Logger . success (
@@ -45,7 +46,7 @@ export class FileService {
4546 }
4647
4748 genTest ( template : string ) {
48- const filePath = this . getFilePath ( EXT . component , ' test' ) ;
49+ const filePath = this . getFilePath ( config . ext . component , config . prefixes . test ) ;
4950 if ( ! fs . pathExistsSync ( filePath ) ) {
5051 fs . writeFileSync ( filePath , template ) ;
5152 Logger . success (
0 commit comments