Skip to content

Commit

Permalink
add small ignore time for package.json files
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Walker-GM committed Aug 22, 2024
1 parent 6a83750 commit 2f6d211
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tasks/framework-tools/frameworkSyncToProject.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,19 @@ async function main() {
process.on('SIGINT', closeWatcher)
process.on('exit', closeWatcher)

let lastSyncEndedAt = 0
watcher.on('all', async (event, filePath) => {
// We ignore changes that happen to package.json files that could have occurred
// as a result of the project syncing process. We do this by ignoring changes to
// those files that are registered within a short period after the sync process
// has ended - because events are being emitted only after the process has ended.
if (
Date.now() - lastSyncEndedAt < 8_000 &&
filePath.endsWith('package.json')
) {
return
}

logStatus(`${event}: ${filePath}`)

if (filePath.endsWith('package.json')) {
Expand Down Expand Up @@ -285,6 +297,7 @@ async function main() {

logStatus(`Done, and waiting for changes...`)
console.log(separator)
lastSyncEndedAt = Date.now()
})
}

Expand Down

0 comments on commit 2f6d211

Please sign in to comment.