Skip to content

Commit

Permalink
Remove optimist dep, clean lib/configuration/load, added comments to …
Browse files Browse the repository at this point in the history
…bin/sails-lift.
  • Loading branch information
mikermcneil committed Mar 1, 2014
1 parent 77e6d86 commit 70abade
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
7 changes: 3 additions & 4 deletions bin/sails-lift.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ var package = require('../package.json')
, captains = require('captains-log')
, path = require('path');

require('colors');


/**
Expand All @@ -27,6 +26,7 @@ module.exports = function () {
var log = captains(rconf.log);

console.log();
require('colors');
log.info('Starting app...'.grey);
console.log();

Expand All @@ -36,11 +36,10 @@ module.exports = function () {
sailsPackageJSON: package
}, rconf);

// Use the app's local Sails in `node_modules` if one exists
var appPath = process.cwd();

// Use the app's local Sails in `node_modules` if it's extant and valid
var localSailsPath = path.resolve(appPath, 'node_modules/sails');

// But first make sure it'll work...
if ( Sails.isLocalSailsValid(localSailsPath, appPath) ) {
require(localSailsPath).lift(scope);
return;
Expand Down
29 changes: 14 additions & 15 deletions lib/configuration/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ module.exports = function (sails) {
* Module dependencies.
*/

var util = require('sails-util'),
async = require('async'),
CaptainsLog = require('captains-log'),
argv = require('optimist').argv;
var util = require('sails-util'),
_ = require('lodash'),
async = require('async'),
path = require('path'),
CaptainsLog = require('captains-log');


/**
Expand Down Expand Up @@ -44,15 +45,16 @@ module.exports = function (sails) {
*/
mapOverrides: function (cb) {

// Take the overrides + app path
// and clone and save them for later
var overrides = util.cloneDeep(sails.config || {});
// Clone the `overrides` that were passed in.
var overrides = _.cloneDeep(sails.config || {});

// TODO: bring the rconf stuff from bin/sails-lift in here

// Command-line arguments take highest precedence
overrides = util.merge(overrides, argv);
// overrides = _.merge(overrides, argv);

// Map Sails options from overrides
overrides = util.merge(overrides, {
overrides = _.merge(overrides, {

// `--verbose` command-line argument
// `--silly` command-line argument
Expand Down Expand Up @@ -97,8 +99,8 @@ module.exports = function (sails) {
*/
versionAndDependencyInfo: function (cb) {

var packageJSONPath = __dirname + '/../../';
util.getPackage(packageJSONPath, function (err, json) {
var pathToThisVersionOfSails = require('path').jsoin__dirname + '/../../';
util.getPackage(pathToThisVersionOfSails, function (err, json) {
if (err) return cb(err);

sails.version = json.version;
Expand Down Expand Up @@ -129,10 +131,7 @@ module.exports = function (sails) {
var implicitDefaults = Configuration.defaults(overrides.appPath || process.cwd());

// Extend copy of implicit defaults with user config
var mergedConfig =
util.merge(
util.cloneDeep(implicitDefaults),
overrides);
var mergedConfig = _.merge(_.cloneDeep(implicitDefaults), overrides);

// Override the environment variable so express and other modules
// which expect NODE_ENV to be set mirror the configured Sails environment.
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"sails-stringfile": "~0.3.0",
"async": "~0.2.9",
"lodash": "~2.4.1",
"optimist": "~0.3.4",
"captains-log": "~0.11.1",
"reportback": "~0.1.4",
"sails-util": "~0.10.0",
Expand Down

0 comments on commit 70abade

Please sign in to comment.