feathers-starter-react-redux-login-roles
feathers-starter-react-redux-login-roles copied to clipboard
/logs/server.log missing: preventing npm start out of box
May be no good way around this, as I understand the need to .gitignore /logs but the lack of /logs/server.log is preventing npm start to work out of the box (until that directory and file is created). Is there a way to create the file on npm start if it doesn't exist?
Suppose this could work in package.json "start:dev": "mkdir logs && touch logs/server.log && NODE_ENV=development node server/index.js",
You could, for instance, short circuit the startup script by having a bash script check if the file exists and create it where it doesn't. Then let the bash script finish by calling the npm start script as normal.
In your package.json create another script named "setup" maybe like:
"setup": "bash ./setup.sh"
Then create a file in the root of your project called setup.sh with the following
#!/bin/bash
# Check for directory "logs" in project root
if [ ! -d ./logs ]; then
mkdir ./logs
fi
# Check for file and create if it doesn't exist
if [ ! -e ./logs/server.log ]; then
touch ./logs/server.log
fi
npm run start # or npm run start:dev
Then just run npm run setup
In the above example it will create either the directory and the file or just file if it doesn't exist. Either way this will result in starting the app. After that all future startups can use npm start or npm run start:dev directly.
Any solution should work on Windows as well. Feathersjs has switched to shx instead of using limited things like rimraf.
I'll do something on the refresh needed once Feathersjs Auk lands.