File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -904,11 +904,11 @@ async function build() {
904
904
* @throws {Error } If the file is still missing or busy after the specified number of tries
905
905
*/
906
906
async function readFileWithRetries ( path , tries = 5 ) {
907
- for ( let n = 0 ; n < tries ; n ++ ) {
907
+ for ( let n = 0 ; n <= tries ; n ++ ) {
908
908
try {
909
909
return await fs . promises . readFile ( path , 'utf8' )
910
910
} catch ( err ) {
911
- if ( n < tries ) {
911
+ if ( n !== tries ) {
912
912
if ( err . code === 'ENOENT' || err . code === 'EBUSY' ) {
913
913
await new Promise ( ( resolve ) => setTimeout ( resolve , 10 ) )
914
914
@@ -935,7 +935,11 @@ async function build() {
935
935
return
936
936
}
937
937
938
- filePath = path . resolve ( meta . watchedPath , filePath )
938
+ let watchedPath = path . resolve ( meta . watchedPath )
939
+
940
+ // Watched path might be the file itself
941
+ // Or the directory it is in
942
+ filePath = watchedPath . endsWith ( filePath ) ? watchedPath : path . resolve ( watchedPath , filePath )
939
943
940
944
// Skip since we've already queued a rebuild for this file that hasn't happened yet
941
945
if ( pendingRebuilds . has ( filePath ) ) {
You can’t perform that action at this time.
0 commit comments