Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delay before command runs #82

Closed
Daviid-P opened this issue Aug 8, 2023 · 4 comments
Closed

delay before command runs #82

Daviid-P opened this issue Aug 8, 2023 · 4 comments

Comments

@Daviid-P
Copy link

Daviid-P commented Aug 8, 2023

Sometimes I made small changes and press ctrl + s by muscle memory.

Would it be possible to add some kind of delay so that it waits n milliseconds before running the command and if before that time the document is saved again the timer starts again from n?

@EyMaddis
Copy link

I think runOnSave runs only again after the first command finishes unless you are using isAsync: true.
And a delay can be done by sleep 1 && ./yourCommand (waits 1 second)

@Daviid-P
Copy link
Author

Wouldn't that still run the command as many times as I pressed save?

What I'm looking for is a delay before running the command so however many times I press save, the timer gets reset and at the end, if the timer runs out, the command is run only once.

@EyMaddis
Copy link

Could be but you need to try it out :)
You could work around it by adapting a script that writes a simple lock file somewhere, like .runOnSaveLock. If that file exists, skip execution.
Looking at the state of this repo, I guess you would need to introduce it via a PR yourself, if you want it

@Daviid-P
Copy link
Author

I didn't even notice last update was 4 years ago, I'll go with the lock file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants