Skip to content

Commit

Permalink
fix: time interval
Browse files Browse the repository at this point in the history
  • Loading branch information
jts04 committed Dec 29, 2023
1 parent a2da2f5 commit 97a4ab1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
11 changes: 8 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,21 @@ async function run() {
const SyncModel = mongoose.model('sync', Sync);
let found = undefined

const intervalId = setInterval(async () => {
const wait = async () => {
found = await SyncModel.findOne({})
if (found.count == 0) {
clearInterval(intervalId)
found = await SyncModel.findOneAndUpdate({}, {count: found.count + 1}, {new: true})
await standardVersion(getConfiguration());
await SyncModel.findOneAndUpdate({}, {count: found.count - 1}, {new: true})
mongoose.disconnect()
} else {
setTimeout(() => {
wait()
}, 1000);
}
}, 1000);
}

wait()
} catch (error) {
core.setFailed(error.stack);
}
Expand Down

0 comments on commit 97a4ab1

Please sign in to comment.