diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..977e762 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true + +[*.{diff,md}] +trim_trailing_whitespace = false \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..96c4e7d --- /dev/null +++ b/.gitattributes @@ -0,0 +1,31 @@ +# Handle line endings automatically for files detected as text +# and leave all files detected as binary untouched. +# Set the default behavior, in case people don't have core.autocrlf set. +* text=auto + +# Force the following filetypes to have unix eols, so Windows does not break them +*.* text eol=lf + +# Denote all files that are truly binary and should not be modified. (bit overkill for this project, but better safe than sorry) +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.ico binary +*.mov binary +*.mp4 binary +*.mp3 binary +*.flv binary +*.fla binary +*.swf binary +*.gz binary +*.zip binary +*.7z binary +*.ttf binary +*.eot binary +*.woff binary +*.pyc binary +*.pdf binary +*.ez binary +*.bz2 binary +*.swp binary \ No newline at end of file diff --git a/README.md b/README.md index ea17b94..23b5684 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,24 @@ docker run --link virtuoso:database \ semtech/mu-javascript-template ``` +#### On Windows: +You might notice that code reloading doesn't work when you mount your code from a Windows host machine. + +It turns out nodemon --watch won't work if your code resides on Windows, but --legacy-watch should. +It's less efficient and more error-prone than --watch, but at least it works. + +Set the `DEV_OS` environment variable to `windows` so `boot.sh` will use --legacy-watch, and you should have live-reload. + +``` +docker run --link virtuoso:database \ + -v `pwd`:/app \ + -p 8888:80 \ + -e NODE_ENV=development \ + -e DEV_OS=windows \ + --name my-js-test \ + semtech/mu-javascript-template +``` + ### Develop in mu.semte.ch stack When developing inside an existing mu.semte.ch stack, it is easiest to set the development mode and mount the sources directly. This makes it easy to setup links to the database and the dispatcher. diff --git a/boot.sh b/boot.sh index 20961a6..d3c2cf9 100755 --- a/boot.sh +++ b/boot.sh @@ -1,4 +1,16 @@ -if [ "$NODE_ENV" == "development" ] +if [ "$NODE_ENV" == "development" -a "$DEV_OS" == "windows" ] +then + # Run live-reload development with legacy-watch + # It's important to go to the right directory first, and to ignore the /usr/src/app/ and /tmp/ directories, since legacy-watch will match any file matching the **.* pattern + # not ignoring these paths will result in an infinite restart loop, as run-development.sh writes to these directories + cd /app/ + exec /usr/src/app/node_modules/.bin/nodemon \ + --legacy-watch /app \ + --ignore /usr/src/app/ \ + --ignore /tmp/ \ + --ext js,mjs,cjs,json \ + --exec /usr/src/app/run-development.sh +elif [ "$NODE_ENV" == "development" ] then # Run live-reload development exec /usr/src/app/node_modules/.bin/nodemon \