11import fs from 'fs-extra' ;
22import path from 'path' ;
33
4- import { CONFIG , EXT } from '../constants' ;
4+ import { CONFIG , EXT , APP_ROOT } from '../constants' ;
55import { Logger } from './Logger' ;
66
77export class FileService {
@@ -23,7 +23,10 @@ export class FileService {
2323 const filePath = this . getFilePath ( EXT . component ) ;
2424 if ( ! fs . pathExistsSync ( filePath ) ) {
2525 fs . writeFileSync ( filePath , template ) ;
26- Logger . success ( chalk => `Successfully generated component file ${ chalk . white ( filePath ) } ` ) ;
26+ Logger . success (
27+ chalk =>
28+ `Successfully generated component file ${ chalk . white ( path . relative ( APP_ROOT , filePath ) ) } `
29+ ) ;
2730 } else {
2831 Logger . warn ( chalk => `File already exists ${ chalk . white ( filePath ) } ` ) ;
2932 }
@@ -33,7 +36,10 @@ export class FileService {
3336 const filePath = this . getFilePath ( EXT . style , 'style' ) ;
3437 if ( ! fs . pathExistsSync ( filePath ) ) {
3538 fs . writeFileSync ( filePath , template ) ;
36- Logger . success ( chalk => `Successfully generated style file ${ chalk . white ( filePath ) } ` ) ;
39+ Logger . success (
40+ chalk =>
41+ `Successfully generated style file ${ chalk . white ( path . relative ( APP_ROOT , filePath ) ) } `
42+ ) ;
3743 } else {
3844 Logger . warn ( chalk => `File already exists ${ chalk . white ( filePath ) } ` ) ;
3945 }
@@ -43,7 +49,10 @@ export class FileService {
4349 const filePath = this . getFilePath ( EXT . component , 'test' ) ;
4450 if ( ! fs . pathExistsSync ( filePath ) ) {
4551 fs . writeFileSync ( filePath , template ) ;
46- Logger . success ( chalk => `Successfully generated test file ${ chalk . white ( filePath ) } ` ) ;
52+ Logger . success (
53+ chalk =>
54+ `Successfully generated test file ${ chalk . white ( path . relative ( APP_ROOT , filePath ) ) } `
55+ ) ;
4756 } else {
4857 Logger . warn ( chalk => `File already exists ${ chalk . white ( filePath ) } ` ) ;
4958 }
0 commit comments