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

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

Open
matthabermehl opened this issue Feb 9, 2017 · 4 comments
Open

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

matthabermehl opened this issue Feb 9, 2017 · 4 comments

Comments

@matthabermehl
Copy link

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
Copy link
Author

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

@jbool24
Copy link

jbool24 commented Feb 23, 2017

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.

@eddyystop
Copy link
Owner

eddyystop commented Feb 24, 2017

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

@eddyystop
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants