0

I am trying to do something like this to automate watchcompile and browser-sync but it's not working.

#!/bin/sh
nvm use 0.10
watchcompile
browser-sync start --server --files "index.html, css/*.css, js/*.js"

This is to be run in the project directory.

Running the above gives me the following:

./watch.sh: line 2: nvm: command not found
./watch.sh: line 3: watchcompile: command not found
./watch.sh: line 4: browser-sync: command not found

watchcompile and browser-sync should be separate processes.

Any help will be greatly appreciated.

1 Answers1

0

This is how I solved it:

I added this to ~/.bash_profile. This adds the nvm directory to PATH:

export PATH="~/.nvm/v0.10.33/bin/:$PATH"

I then added these lines to watch.sh:

#!/bin/bash
watchcompile &
ps -eaf | grep watchcompile
cd htdocs
browser-sync start --server --files "index.html, css/*.css, js/*.js" &
ps -eaf | grep browser-sync

The & at the end of line 2 and 5 makes the command run in the background, and the two

ps -eaf | grep command

lines are just there to give me the process ids of the background processes so that I may later kill them.

I am sure there is a better way to do this, but at least this works.