forked from balderdashy/sails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sails-new.js
52 lines (35 loc) · 951 Bytes
/
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
#!/usr/bin/env node
/**
* Module dependencies
*/
var package = require('../package.json')
, rconf = require('../lib/configuration/rc')
, _ = require('lodash')
, path = require('path')
, sailsgen = require('sails-generate');
/**
* `sails new`
*
* Generate a new Sails app.
*/
module.exports = function ( ) {
// Build initial scope
var scope = {
rootPath: process.cwd(),
modules: {},
sailsRoot: path.resolve(__dirname, '..'),
sailsPackageJSON: package,
viewEngine: rconf.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);
var cliArguments = Array.prototype.slice.call(arguments);
// Remove commander's extra argument
cliArguments.pop();
scope.generatorType = 'new';
scope.args = cliArguments;
return sailsgen( scope, {success: function(){}} );
};