Skip to content

Commit

Permalink
fix: only show waiting message once
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Apr 21, 2018
1 parent 7dcdab8 commit 5c75700
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/commands/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,18 @@ export default class UpdateCommand extends Command {

// when autoupdating, wait until the CLI isn't active
private async debounce(): Promise<void> {
let output = false
const lastrunfile = path.join(this.config.cacheDir, 'lastrun')
const m = await this.mtime(lastrunfile)
m.setHours(m.getHours() + 1)
if (m > new Date()) {
await cli.log(`waiting until ${m.toISOString()} to update`)
const msg = `waiting until ${m.toISOString()} to update`
if (output) {
this.debug(msg)
} else {
await cli.log(msg)
output = true
}
await wait(60 * 1000) // wait 1 minute
return this.debounce()
}
Expand Down

0 comments on commit 5c75700

Please sign in to comment.