File tree 4 files changed +36
-23
lines changed
4 files changed +36
-23
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ Go to the `v1` branch to see the changelog of Lume 1.
80
80
- Parsing the escaped URLs in CSS files.
81
81
- Improved the output CSS and JS code of components.
82
82
- Components interoperability, specially between JSX vs text engines.
83
+ - Improved reload after renaming or removing a folder.
83
84
84
85
[ #660 ] : https://github.com/lumeland/lume/issues/660
85
86
[ #736 ] : https://github.com/lumeland/lume/issues/736
Original file line number Diff line number Diff line change @@ -93,15 +93,6 @@ export default class FS {
93
93
entry . src = src ;
94
94
}
95
95
96
- // New directory, walk it
97
- if ( entry . type === "directory" ) {
98
- if ( ! exist ) {
99
- this . #walkFs( entry ) ;
100
- }
101
-
102
- return ;
103
- }
104
-
105
96
try {
106
97
entry . getInfo ( ) ;
107
98
} catch ( error ) {
@@ -117,6 +108,11 @@ export default class FS {
117
108
return exist ;
118
109
}
119
110
}
111
+
112
+ // New directory, walk it
113
+ if ( entry . type === "directory" && ! exist ) {
114
+ this . #walkFs( entry ) ;
115
+ }
120
116
}
121
117
122
118
#isValid( path : string ) {
Original file line number Diff line number Diff line change @@ -628,12 +628,13 @@ export default class Site {
628
628
}
629
629
630
630
// Remove pages or static files depending on this entry
631
- const pages = this . pages . filter ( ( page ) => page . src . entry === entry ) . map ( (
632
- page ,
633
- ) => page . outputPath ) ;
634
- const files = this . files . filter ( ( file ) => file . src . entry === entry ) . map ( (
635
- file ,
636
- ) => file . outputPath ) ;
631
+ const pages = this . pages
632
+ . filter ( ( page ) => pathBelongs ( entry . path , page . src . entry ?. path ) )
633
+ . map ( ( page ) => page . outputPath ) ;
634
+ const files = this . files
635
+ . filter ( ( file ) => pathBelongs ( entry . path , file . src . entry ?. path ) )
636
+ . map ( ( file ) => file . outputPath ) ;
637
+
637
638
await this . writer . removeFiles ( [ ...pages , ...files ] ) ;
638
639
}
639
640
@@ -1106,3 +1107,10 @@ export type SiteEventType = keyof SiteEventMap;
1106
1107
1107
1108
/** A generic Lume plugin */
1108
1109
export type Plugin = ( site : Site ) => void ;
1110
+
1111
+ function pathBelongs ( base : string , path ?: string ) : boolean {
1112
+ if ( ! path ) {
1113
+ return false ;
1114
+ }
1115
+ return base === path || path ?. startsWith ( base + "/" ) ;
1116
+ }
Original file line number Diff line number Diff line change @@ -176,19 +176,27 @@ export class FSWriter implements Writer {
176
176
const outputPath = posix . join ( this . dest , file ) ;
177
177
this . #outputs. delete ( outputPath . toLowerCase ( ) ) ;
178
178
await Deno . remove ( outputPath ) ;
179
+
179
180
// Remove empty directories
180
- const dir = posix . dirname ( outputPath ) ;
181
- try {
182
- if ( dir !== this . dest ) {
183
- await Deno . remove ( dir ) ;
184
- }
185
- } catch {
186
- // Ignored
187
- }
181
+ removeEmptyDirectory ( outputPath , this . dest ) ;
188
182
} catch {
189
183
// Ignored
190
184
}
191
185
} ,
192
186
) ;
193
187
}
194
188
}
189
+
190
+ function removeEmptyDirectory ( path : string , base : string ) {
191
+ const dir = posix . dirname ( path ) ;
192
+
193
+ try {
194
+ if ( dir !== base ) {
195
+ Deno . removeSync ( dir ) ;
196
+ // Check if the parent directory is also empty
197
+ removeEmptyDirectory ( dir , base ) ;
198
+ }
199
+ } catch {
200
+ // Ignored
201
+ }
202
+ }
You can’t perform that action at this time.
0 commit comments