schell / steeloverseer

A file watcher and development tool.
BSD 3-Clause "New" or "Revised" License
128 stars 15 forks source link

Run Commands on First Start #18

Open xanderdunn opened 7 years ago

xanderdunn commented 7 years ago

It would be nice if there were an option to run the commands on first start before any of the files change. This is useful when starting up a server.

mitchellwrosen commented 7 years ago

Can you give an example? If you don't want to re-run commands on file-change, then wouldn't

thing1 && thing2 && sos .

suffice?

schell commented 7 years ago

@xanderdunn it's a bit more complicated than simply running the commands because you can have many patterns that if matched, run a chain of commands. Those commands could interfere with each other, launch nukes, etc. In order to do this correctly I think we'd need to be able to specify which commands or patterns you'd like run at startup, but then it is probably easier just to use your shell like @mitchellwrosen suggested. Thoughts?

xanderdunn commented 7 years ago

Thanks. I have a REST API in Haskell. I was trying to emulate npm run watch, which executes a server and updates it every time files are changed.

Currently, running just sos does the "updates it every time files are changed" for me with:

- patterns:
  - .*\.hs$
  - ^my-thing.cabal$
  - ^stack.yam$
  commands:
  - stack build --pedantic
  - stack exec api-hs-exe

Yeah, running stack build --pedantic && stack exec api-hs-exe && sos does the trick. It's a matter of convenience. I assumed steeloverseer would come with like an sos -f that would do the same thing.

mitchellwrosen commented 7 years ago

It certainly wouldn't be hard to add, would you be willing to put in a PR? (Btw - I've been meaning to simplify the codebase for a while now).

In the meantime,

$ sos
$ touch stack.yaml

doesn't seem too difficult :)

schell commented 7 years ago

@xanderdunn right - npm run watch is a bit more specific since (I'm guessing) there is a run command/function/script that is defined in the package/project config. sos is more general in that it runs any shell commands and is not solely focused on building and recompiling projects - though that is what we use it for, mostly ;)