diff options
author | Peter Wu <peter@lekensteyn.nl> | 2015-05-07 10:28:16 +0200 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2015-05-07 10:28:16 +0200 |
commit | c47af89c818fd4e7a32e1621d264a19d49facd69 (patch) | |
tree | bc4587849c71941f485643dd790c1c9ff79e0b5a | |
parent | 7161d6293b83f359646814f2e1cdfa02e6162c2a (diff) | |
download | n-c47af89c818fd4e7a32e1621d264a19d49facd69.tar.gz |
Add gulp task to start mongod
For development purposes.
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | gulpfile.js | 23 |
2 files changed, 24 insertions, 0 deletions
@@ -1,3 +1,4 @@ node_modules/ +db/data/ .*.sw? diff --git a/gulpfile.js b/gulpfile.js index f4160c3..a1bfd3d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,6 +1,8 @@ 'use strict'; +var fs = require('fs'); var gulp = require('gulp'); var server = require('gulp-express'); +var spawn = require('child_process').spawn; var pkg = require('./package.json'); gulp.task('server', function() { @@ -12,5 +14,26 @@ gulp.task('server', function() { gulp.watch([pkg.main], [server.run]); }); +/** Creates a directory tree if it does not yet exist. */ +function makedirs(path) { + var dirPath = '.'; + path.split('/').forEach(function(dir) { + dirPath += '/' + dir; + if (!fs.existsSync(dirPath)) { + fs.mkdirSync(dirPath); + } + }); +} + +gulp.task('mongod', function() { + makedirs('db/data'); + // listen on localhost instead of wildcard for security reasons. + spawn('mongod', [ + '--dbpath', 'db/data', + '--nounixsocket', + '--bind_ip', '127.0.0.1', + ]); +}); + // Lazy me, make "gulp" the same as "gulp server" for now. gulp.task('default', ['server']); |