@@ -13,6 +13,7 @@ import {
13
13
initJsxFilePath ,
14
14
} from "../consts" ;
15
15
import { buildClassList } from "../utils/build-class-list" ;
16
+ import { createInitLogger } from "../utils/create-init-logger" ;
16
17
import { extractComponentImports } from "../utils/extract-component-imports" ;
17
18
import { findFiles } from "../utils/find-files" ;
18
19
import { getClassList } from "../utils/get-class-list" ;
@@ -25,6 +26,7 @@ export async function dev() {
25
26
await setupOutputDirectory ( ) ;
26
27
let config = await getConfig ( ) ;
27
28
await setupInit ( config ) ;
29
+ const initLogger = createInitLogger ( config ) ;
28
30
29
31
if ( config . components . length ) {
30
32
console . warn ( automaticClassGenerationMessage ) ;
@@ -42,12 +44,15 @@ export async function dev() {
42
44
for ( const file of files ) {
43
45
const content = await fs . readFile ( file , "utf-8" ) ;
44
46
const componentImports = extractComponentImports ( content ) ;
47
+ initLogger . check ( file , content ) ;
45
48
46
49
if ( componentImports . length ) {
47
50
importedComponentsMap [ file ] = componentImports ;
48
51
}
49
52
}
50
53
54
+ initLogger . log ( ) ;
55
+
51
56
const newImportedComponents = [ ...new Set ( Object . values ( importedComponentsMap ) . flat ( ) ) ] ;
52
57
const newClassList = buildClassList ( {
53
58
components : config . components . length ? config . components : newImportedComponents ,
@@ -63,9 +68,19 @@ export async function dev() {
63
68
64
69
// watch for changes
65
70
async function handleChange ( path : string , eventName : "change" | "unlink" ) {
71
+ if ( [ configFilePath , initFilePath , initJsxFilePath ] . includes ( path ) ) {
72
+ config = await getConfig ( ) ;
73
+ await setupInit ( config ) ;
74
+ initLogger . config = config ;
75
+ }
76
+ if ( path === gitIgnoreFilePath ) {
77
+ await setupGitIgnore ( ) ;
78
+ }
79
+
66
80
if ( eventName === "change" ) {
67
81
const content = await fs . readFile ( path , "utf-8" ) ;
68
82
const componentImports = extractComponentImports ( content ) ;
83
+ initLogger . check ( path , content ) ;
69
84
70
85
if ( componentImports . length ) {
71
86
importedComponentsMap [ path ] = componentImports ;
@@ -75,17 +90,12 @@ export async function dev() {
75
90
}
76
91
if ( eventName === "unlink" ) {
77
92
delete importedComponentsMap [ path ] ;
93
+ initLogger . checkedMap . delete ( path ) ;
78
94
}
79
95
80
- const newImportedComponents = [ ... new Set ( Object . values ( importedComponentsMap ) . flat ( ) ) ] ;
96
+ initLogger . log ( ) ;
81
97
82
- if ( [ configFilePath , initFilePath , initJsxFilePath ] . includes ( path ) ) {
83
- config = await getConfig ( ) ;
84
- await setupInit ( config ) ;
85
- }
86
- if ( path === gitIgnoreFilePath ) {
87
- await setupGitIgnore ( ) ;
88
- }
98
+ const newImportedComponents = [ ...new Set ( Object . values ( importedComponentsMap ) . flat ( ) ) ] ;
89
99
90
100
const newClassList = buildClassList ( {
91
101
components : config . components . length ? config . components : newImportedComponents ,
0 commit comments