Skip to content

Commit 3e88257

Browse files
committed
refactor, make lift work
1 parent 6c22780 commit 3e88257

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

bin/sails-generate.js

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ module.exports = function () {
4040
// `scope.generators.modules` as needed (simpler)
4141
_.merge(scope, config);
4242

43-
console.log(config);
4443

4544
var cliArguments = Array.prototype.slice.call(arguments);
4645

bin/sails-lift.js

+24-9
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
* Module dependencies
66
*/
77

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');
1114

1215

1316

@@ -16,29 +19,41 @@ var Sails = require('../lib/app')
1619
*
1720
* Expose method which lifts the appropriate instance of Sails.
1821
* (Fire up the Sails app in our working directory.)
19-
*
20-
* @param {Object} options - to pass to sails.lift()
2122
*/
2223

2324
module.exports = function () {
2425

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);
2742

2843
// Use the app's local Sails in `node_modules` if one exists
2944
var appPath = process.cwd();
3045
var localSailsPath = path.resolve(appPath, '/node_modules/sails', '/lib');
3146

3247
// But first make sure it'll work...
3348
if ( Sails.isLocalSailsValid(localSailsPath, appPath) ) {
34-
require(localSailsPath).lift(options);
49+
require(localSailsPath).lift(scope);
3550
return;
3651
}
3752

3853
// Otherwise, if no workable local Sails exists, run the app
3954
// using the currently running version of Sails. This is
4055
// probably always the global install.
4156
var globalSails = new Sails();
42-
globalSails.lift(options);
57+
globalSails.lift(scope);
4358
return;
4459
};

0 commit comments

Comments
 (0)