From c47af89c818fd4e7a32e1621d264a19d49facd69 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Thu, 7 May 2015 10:28:16 +0200 Subject: Add gulp task to start mongod For development purposes. --- gulpfile.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'gulpfile.js') 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']); -- cgit v1.2.1