feathers-starter-react-redux-login-roles icon indicating copy to clipboard operation
feathers-starter-react-redux-login-roles copied to clipboard

/logs/server.log missing: preventing npm start out of box

Open matthabermehl opened this issue 8 years ago • 4 comments

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?

matthabermehl avatar Feb 09 '17 17:02 matthabermehl

Suppose this could work in package.json "start:dev": "mkdir logs && touch logs/server.log && NODE_ENV=development node server/index.js",

matthabermehl avatar Feb 09 '17 17:02 matthabermehl

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.

jbool24 avatar Feb 23 '17 19:02 jbool24

Any solution should work on Windows as well. Feathersjs has switched to shx instead of using limited things like rimraf.

eddyystop avatar Feb 24 '17 13:02 eddyystop

I'll do something on the refresh needed once Feathersjs Auk lands.

eddyystop avatar Feb 24 '17 13:02 eddyystop