5
5
* Module dependencies
6
6
*/
7
7
8
- var Sails = require ( '../lib/app' )
9
- , path = require ( 'path' )
10
- , captains = require ( 'captains-log' ) ;
8
+ var package = require ( '../package.json' )
9
+ , Sails = require ( '../lib/app' )
10
+ , rc = require ( 'rc' )
11
+ , reportback = require ( 'reportback' ) ( )
12
+ , _ = require ( 'lodash' )
13
+ , path = require ( 'path' ) ;
11
14
12
15
13
16
@@ -16,29 +19,41 @@ var Sails = require('../lib/app')
16
19
*
17
20
* Expose method which lifts the appropriate instance of Sails.
18
21
* (Fire up the Sails app in our working directory.)
19
- *
20
- * @param {Object } options - to pass to sails.lift()
21
22
*/
22
23
23
24
module . exports = function ( ) {
24
25
25
- var config = { } ;
26
- var log = captains ( config . log ) ;
26
+ // Get CLI configuration
27
+ var config = rc ( 'sails' ) ;
28
+
29
+
30
+ // Build initial scope
31
+ var scope = {
32
+ rootPath : process . cwd ( ) ,
33
+ sailsPackageJSON : package
34
+ } ;
35
+
36
+ // Mix-in rc config
37
+ _ . merge ( scope , config . generators ) ;
38
+
39
+ // TODO: just do a top-level merge and reference
40
+ // `scope.generators.modules` as needed (simpler)
41
+ _ . merge ( scope , config ) ;
27
42
28
43
// Use the app's local Sails in `node_modules` if one exists
29
44
var appPath = process . cwd ( ) ;
30
45
var localSailsPath = path . resolve ( appPath , '/node_modules/sails' , '/lib' ) ;
31
46
32
47
// But first make sure it'll work...
33
48
if ( Sails . isLocalSailsValid ( localSailsPath , appPath ) ) {
34
- require ( localSailsPath ) . lift ( options ) ;
49
+ require ( localSailsPath ) . lift ( scope ) ;
35
50
return ;
36
51
}
37
52
38
53
// Otherwise, if no workable local Sails exists, run the app
39
54
// using the currently running version of Sails. This is
40
55
// probably always the global install.
41
56
var globalSails = new Sails ( ) ;
42
- globalSails . lift ( options ) ;
57
+ globalSails . lift ( scope ) ;
43
58
return ;
44
59
} ;
0 commit comments