简体   繁体   中英

How to use nodejs or gulp to execute a series of shell commands?

I am working in the development on my mac laptop. Here are what I need to do to start the development environment:

1) open console, 'sudo mongod' - start mongoDB server

2) open another console, 'mongo' - open mongo console for debug CRUD process

3) open another console, 'cd /projects/myProject', 'npm start' - start the nodejs api service on localhost

4) open another console, and 'cd /projects/myProject', 'gulp' - start the gulp browserify & watch process

5) open another console, 'cd /projects/myProject/build', 'httpster' - start a mini http server for front-end built code, so that I can access it in browser at 0.0.0.0: 3333

If you do those everyday, it is not fun at all. I think it is a common problem which is very likely to have a solution. Is there anyway to complete all above by executing one single js file? eg: node start.js. If would be best if you can provide some demo code.

Thank you!

  • Nick

You can use gulp-shell . I use it to start mongoDB from gulp.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM