forked from balderdashy/sails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsails-generate.js
49 lines (33 loc) · 934 Bytes
/
sails-generate.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
#!/usr/bin/env node
/**
* Module dependencies
*/
var package = require('../package.json')
, reportback = require('reportback')()
, rc = require('rc')
, _ = require('lodash')
, sailsgen = require('sails-generate');
/**
* `sails generate`
*
* Generate module(s) for the app in our working directory.
* Internally, uses ejs for rendering the various module templates.
*/
module.exports = function () {
// Get CLI configuration
var config = rc('sails');
// Build initial scope
var scope = {
rootPath: process.cwd(),
sailsPackageJSON: package
};
// Mix-in rc config
_.merge(scope, config.generators);
var cliArguments = Array.prototype.slice.call(arguments);
// Remove commander's extra argument
cliArguments.pop();
// Peel off the generatorType and the rest of the args
scope.generatorType = cliArguments.shift();
scope.args = cliArguments;
return sailsgen( scope, reportback.extend() );
};