Search code examples
bashember-cliwatchman

Shell build script with ember


I am attempting to write a build script to be used with Facebook watchman and my ember-cli application.

My build script is:

#!/bin/sh

cd ..
ember build
cd ..
cp ./ember-app/dist/index.html ./slim-app/app/templates/app.php
cp -r ./ember-app/dist/assets/ ./slim-app/public/assets/

And my watchman command is:

watchman -- trigger $PWD/ember-app/app 'ember-build' '**' -- sh $PWD/build.sh

Watchman triggers and finds my script fine but when I look at the log I get an error saying ember cannot be found. I'm not really sure why because when i run sh build.sh everything works fine.

Is there any way I could do something like which ember to determine the path to ember and use it directly? I know I can just do which ember and copy and paste that path into the script but I really don't want to do that because I want the build script to work no matter which version of node/nvm I am using.

I'm also open to suggestions to a better way of doing this.


Solution

  • Sounds like a PATH problem. When watchman is first started it captures your PATH environment variable, except on OS X at the moment, due to a bug in our launchd integration. https://github.com/facebook/watchman/issues/68 has some suggestions for an awkward workaround. Another possibility is to simply put a line in your build script to set the PATH:

    # Add the path to ember in here somewhere
    PATH=/usr/local/bin:$PATH