Skip to content

Commit 26d64de

Browse files
committed
refactor: clear screen when watched file is meant to be processed
1 parent c3792f1 commit 26d64de

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Watcher/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,13 @@ export class Watcher {
138138
* New file added
139139
*/
140140
watcher.on('add', async (filePath) => {
141-
this._clearScreen()
142141
const metaData = this.compiler.rcFile.getMetaData(filePath)
143142
if (!metaData.metaFile) {
144143
return
145144
}
146145

146+
this._clearScreen()
147+
147148
this._logger.create(filePath)
148149
await this.compiler.copyFiles([filePath], config.options.outDir!)
149150

@@ -156,12 +157,13 @@ export class Watcher {
156157
* File changed
157158
*/
158159
watcher.on('change', async (filePath) => {
159-
this._clearScreen()
160160
const metaData = this.compiler.rcFile.getMetaData(filePath)
161161
if (!metaData.metaFile) {
162162
return
163163
}
164164

165+
this._clearScreen()
166+
165167
if (metaData.rcFile) {
166168
this._logger.skip('in-process changes to .adonisrc.json file are ignored')
167169
await this.compiler.copyAdonisRcFile(config.options.outDir!)
@@ -179,12 +181,13 @@ export class Watcher {
179181
* File removed
180182
*/
181183
watcher.on('unlink', async (filePath) => {
182-
this._clearScreen()
183184
const metaData = this.compiler.rcFile.getMetaData(filePath)
184185
if (!metaData.metaFile) {
185186
return
186187
}
187188

189+
this._clearScreen()
190+
188191
if (metaData.rcFile) {
189192
this._logger.stop('cannot continue after deletion of .adonisrc.json file')
190193
watcher.chokidar.close()

0 commit comments

Comments
 (0)