forked from maksrom/javascript-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdbLoad.js
More file actions
executable file
·33 lines (24 loc) · 792 Bytes
/
dbLoad.js
File metadata and controls
executable file
·33 lines (24 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var fs = require('fs');
var co = require('co');
var path = require('path');
var gutil = require('gulp-util');
var dataUtil = require('lib/dataUtil');
var mongoose = require('lib/mongoose');
var projectRoot = require('config').projectRoot;
module.exports = function() {
return function() {
var args = require('yargs')
.usage("gulp db:load --from fixture/init")
.example("gulp db:load --from fixture/more --no-reset")
.demand(['from'])
.default('reset', true)
.describe('from', 'file to import')
.argv;
var dbPath = path.join(projectRoot, args.from);
gutil.log("loading db " + dbPath);
return co(function*() {
yield* dataUtil.loadModels(dbPath, { reset: args.reset });
gutil.log("loaded db " + dbPath);
});
};
};