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

Fix/windows dev fixes #25

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
14 changes: 13 additions & 1 deletion boot.sh
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down