forked from balderdashy/sails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsails-new.js
57 lines (42 loc) · 1.16 KB
/
sails-new.js
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env node
/**
* Module dependencies
*/
var nodepath = require('path');
var _ = require('lodash');
var sailsgen = require('sails-generate');
var package = require('../package.json');
var rconf = require('../lib/app/configuration/rc');
/**
* `sails new`
*
* Generate a new Sails app.
*/
module.exports = function() {
// Build initial scope
var scope = {
rootPath: process.cwd(),
modules: {},
sailsRoot: nodepath.resolve(__dirname, '..'),
sailsPackageJSON: package,
viewEngine: rconf.viewEngine
};
// Support --template option for backwards-compat.
if (!scope.viewEngine && rconf.template) {
scope.viewEngine = rconf.template;
}
// Mix-in rconf
_.merge(scope, rconf.generators);
// TODO: just do a top-level merge and reference
// `scope.generators.modules` as needed (simpler)
_.merge(scope, rconf);
// Pass the original CLI arguments down to the generator
// (but first, remove commander's extra argument)
var cliArguments = Array.prototype.slice.call(arguments);
cliArguments.pop();
scope.args = cliArguments;
scope.generatorType = 'new';
return sailsgen(scope, {
success: function() {}
});
};