From 682d80392b499692efd3c067ae4e4fd4b8710bdd Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Tue, 29 Jul 2014 19:14:39 +0200 Subject: [PATCH 01/10] Rough WIP for custom envs --- lib/broccoli/ember-app.js | 72 +++++++++++++++------------------------ lib/models/project.js | 7 ++-- 2 files changed, 33 insertions(+), 46 deletions(-) diff --git a/lib/broccoli/ember-app.js b/lib/broccoli/ember-app.js index 80757fc1e5..bfd1a70bba 100644 --- a/lib/broccoli/ember-app.js +++ b/lib/broccoli/ember-app.js @@ -6,6 +6,7 @@ var p = require('../preprocessors'); var chalk = require('chalk'); var Project = require('../models/project'); +var Config = require('../models/config'); var cleanBaseURL = require('../utilities/clean-base-url'); var preprocessJs = p.preprocessJs; @@ -50,41 +51,22 @@ function EmberApp(options) { this.project = options.project || Project.closestSync(process.cwd()); - this.env = process.env.EMBER_ENV || 'development'; this.name = options.name || this.project.name(); this.registry = options.registry || p.setupRegistry(this); - var isProduction = this.env === 'production'; + this.env = process.env.EMBER_ENV || 'development'; - this.tests = options.hasOwnProperty('tests') ? options.tests : !isProduction; - this.hinting = options.hasOwnProperty('hinting') ? options.hinting : !isProduction; - - if (process.env.EMBER_CLI_TEST_COMMAND) { - this.tests = true; - } + this.getEnvJSON = function () { + return this.project.config(this.env).get('ENV'); + }.bind(this); this.options = merge(options, { - es3Safe: true, - wrapInEval: !isProduction, - minifyCSS: { - enabled: true, - options: { relativeTo: 'app/styles' } - }, - minifyJS: { - enabled: true, - options: { - mangle: true, - compress: true - } - }, - loader: 'vendor/loader/loader.js', trees: {}, - jshintrc: {}, - getEnvJSON: this.project.require(options.environment || './config/environment'), vendorFiles: {} }, defaults); + this.vendorFiles = merge(options.vendorFiles, { 'loader.js': 'vendor/loader/loader.js', 'jquery.js': 'vendor/jquery/dist/jquery.js', @@ -146,10 +128,6 @@ function EmberApp(options) { vendor: unwatchedTree('vendor'), }, defaults); - this.options.jshintrc = merge(this.options.jshintrc, { - app: this.project.root, - tests: path.join(this.project.root, 'tests'), - }, defaults); this.importWhitelist = {}; this.legacyFilesToAppend = []; @@ -216,7 +194,7 @@ EmberApp.prototype.index = memoize(function() { destDir: '/' }); - return injectENVJson(this.options.getEnvJSON, this.env, index, files); + return injectENVJson(this.getEnvJSON, this.env, index, files); }); EmberApp.prototype.testIndex = memoize(function() { @@ -226,7 +204,7 @@ EmberApp.prototype.testIndex = memoize(function() { destDir: '/tests' }); - return injectENVJson(this.options.getEnvJSON, this.env, index, [ + return injectENVJson(this.getEnvJSON, this.env, index, [ 'tests/index.html' ]); }); @@ -298,7 +276,8 @@ EmberApp.prototype.appAndDependencies = memoize(function() { var app = this._processedAppTree(); var templates = this._processedTemplatesTree(); - if (this.options.es3Safe) { + var config = this.project.config(this.env); + if (config.isEnabled('es3Safe')) { app = new ES3SafeFilter(app); } @@ -307,19 +286,19 @@ EmberApp.prototype.appAndDependencies = memoize(function() { var sourceTrees = [ vendor, preprocessedApp, templates ]; - if (this.tests) { + if (config.isEnabled('tests')) { var tests = this._processedTestsTree(); var preprocessedTests = preprocessJs(tests, '/tests', this.name); sourceTrees.push(preprocessedTests); - if (this.hinting) { + if (config.isEnabled('hinting', 'js')) { var jshintedApp = jshintTrees(preprocessedApp, { - jshintrcPath: this.options.jshintrc.app, + jshintrcPath: config.get('hinting', 'js', 'app') || this.project.root, description: 'JSHint - App' }); var jshintedTests = jshintTrees(tests, { - jshintrcPath: this.options.jshintrc.tests, + jshintrcPath: config.get('hinting', 'js', 'tests') || path.join(this.project.root, 'tests'), description: 'JSHint - Tests' }); @@ -355,8 +334,9 @@ EmberApp.prototype.appAndDependencies = memoize(function() { EmberApp.prototype.javascript = memoize(function() { var applicationJs = this.appAndDependencies(); var legacyFilesToAppend = this.legacyFilesToAppend; + var config = this.project.config(this.env); - if (this.tests) { + if (config.isEnabled('tests')) { this.import('vendor/ember-qunit/dist/named-amd/main.js', { exports: { 'ember-qunit': [ @@ -395,8 +375,9 @@ EmberApp.prototype.javascript = memoize(function() { var vendorAndApp = mergeTrees([vendor, es6]); - if (this.env === 'production' && this.options.minifyJS.enabled === true) { - var options = this.options.minifyJS.options || {}; + var config = this.project.config(this.env); + if (config.isEnabled('minify', 'js')) { + var options = config.get('minify', 'js') || {}; return uglifyJavaScript(vendorAndApp, options); } else { return vendorAndApp; @@ -425,8 +406,9 @@ EmberApp.prototype.styles = memoize(function() { description: 'concatFiles - vendorStyles' }); - if (this.env === 'production' && this.options.minifyCSS.enabled === true) { - var options = this.options.minifyCSS.options || {}; + var config = this.project.config(this.env); + if (config.isEnabled('minify', 'css')) { + var options = config.get('minify', 'css') || {}; processedStyles = preprocessMinifyCss(processedStyles, options); vendorStyles = preprocessMinifyCss(vendorStyles, options); } @@ -461,8 +443,9 @@ EmberApp.prototype.testFiles = memoize(function() { destDir: '/' }); - if (this.options.fingerprint && this.options.fingerprint.exclude) { - this.options.fingerprint.exclude.push('testem'); + var config = this.project.config(this.env); + if (config.isEnabled('fingerprint')) { + config.push('fingerprint', 'exclude', 'testem'); } var iconsTree = pickFiles(this.trees.vendor, { @@ -588,7 +571,8 @@ EmberApp.prototype.toArray = function() { sourceTrees.push(publicFolder); } - if (this.tests) { + var config = this.project.config(this.env); + if (config.isEnabled('tests')) { sourceTrees = sourceTrees.concat(this.testIndex(), this.testFiles()); } @@ -607,7 +591,7 @@ EmberApp.prototype.toTree = function(additionalTrees) { function injectENVJson(fn, env, tree, files) { // TODO: real templating var envJsonString = function(){ - return JSON.stringify(fn(env)); + return JSON.stringify(fn()); }; var baseTag = function(){ diff --git a/lib/models/project.js b/lib/models/project.js index 80786a8ff5..e70126c1ab 100644 --- a/lib/models/project.js +++ b/lib/models/project.js @@ -9,6 +9,7 @@ var assign = require('lodash-node/modern/objects/assign'); var DAG = require('../utilities/DAG'); var Command = require('../models/command'); var Addon = require('../models/addon'); +var Config = require('./config'); var emberCLIVersion = require('../utilities/ember-cli-version'); @@ -26,8 +27,10 @@ Project.prototype.isEmberCLIProject = function() { }; Project.prototype.config = function(env) { - if (fs.existsSync(path.join(this.root, 'config', 'environment.js'))) { - return this.require('./config/environment')(env); + if (fs.existsSync(path.join(this.root, 'config', env + '.js'))) { + var config = new Config(); + this.require('./config/' + env)(config); + return config; } else { return { }; } From 007f22f0cfd619d92a397f2e3ea4e788d68f907b Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Tue, 29 Jul 2014 19:29:27 +0200 Subject: [PATCH 02/10] Add config model --- lib/models/config.js | 69 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 lib/models/config.js diff --git a/lib/models/config.js b/lib/models/config.js new file mode 100644 index 0000000000..e0899d4d1e --- /dev/null +++ b/lib/models/config.js @@ -0,0 +1,69 @@ +'use strict'; + +var isObject = require('lodash-node/modern/objects/isObject'); +var isArray = require('lodash-node/modern/objects/isArray'); +var isUndefined = require('lodash-node/modern/objects/isUndefined'); +var defaults = require('lodash-node/modern/objects/defaults'); +var merge = require('lodash-node/modern/objects/merge'); + + +function Config() { + this.options = {}; + this.groupOptions = {}; +} + +// getter +Config.prototype.get = function(group, key) { + var argc = arguments.length, + options = this.options; + + if (argc === 1) { + // group getter + return this.options[group] || false; + } else if (argc === 2) { + if (options[group] !== undefined && options[group][key] !== undefined) { + return options[group][key]; + } else { + return this.get(group); + } + } +} + +// setter +Config.prototype.set = function(group) { + var len = arguments.length; + if(len >= 2 && !isObject(arguments[1])) { + this.groupOptions[arguments[0]] = arguments[1]; + } + + var newOptions; + if (isObject(arguments[1])) { + newOptions = arguments[1]; + } else if (isObject(arguments[2])) { + this.set(group, arguments[1]); + newOptions = arguments[2]; + } + + this.options[group] = merge(newOptions, this.options[group], defaults); +} + +Config.prototype.isEnabled = function() { + return !!this.get.apply(this, arguments); +} + +Config.prototype.debug = function() { + console.log('groupOptions: ', this.groupOptions); + console.log('options: ', this.options); +} + +Config.prototype.push = function (group, key, option) { + if(isUndefined(this.options[group]) || isUndefined(this.options[group][key])) { + this.options[group] = this.options[group] || {}; + this.options[group][key] = []; + } + + this.options[group][key].push(option); +} + + +module.exports = Config; \ No newline at end of file From e645ea2ae16e8cdfdbc58f2af688606d194f47d0 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Tue, 29 Jul 2014 20:14:25 +0200 Subject: [PATCH 03/10] Make tests happier --- blueprints/app/files/config/development.js | 16 ++++++++ blueprints/app/files/config/environment.js | 38 ------------------- blueprints/app/files/config/production.js | 30 +++++++++++++++ blueprints/app/files/config/test.js | 8 ++++ lib/broccoli/ember-app.js | 2 - lib/models/config.js | 13 +++---- .../brocfile-tests/wrap-in-eval/Brocfile.js | 4 +- tests/helpers/mock-project.js | 2 +- tests/unit/models/project-test.js | 6 +-- 9 files changed, 65 insertions(+), 54 deletions(-) create mode 100644 blueprints/app/files/config/development.js delete mode 100644 blueprints/app/files/config/environment.js create mode 100644 blueprints/app/files/config/production.js create mode 100644 blueprints/app/files/config/test.js diff --git a/blueprints/app/files/config/development.js b/blueprints/app/files/config/development.js new file mode 100644 index 0000000000..5f2622c324 --- /dev/null +++ b/blueprints/app/files/config/development.js @@ -0,0 +1,16 @@ +/* jshint node: true */ + +var productionConfig = require('./production.js'); + +module.exports = function(config) { + productionConfig(config); + + config.set('production', false); + config.set('tests', true); + config.set('hinting', true, { + js + }); + + + config.set('wrapInEval', true); +}; diff --git a/blueprints/app/files/config/environment.js b/blueprints/app/files/config/environment.js deleted file mode 100644 index 24065b0b2d..0000000000 --- a/blueprints/app/files/config/environment.js +++ /dev/null @@ -1,38 +0,0 @@ -/* jshint node: true */ - -module.exports = function(environment) { - var ENV = { - environment: environment, - baseURL: '/', - locationType: 'auto', - EmberENV: { - FEATURES: { - // Here you can enable experimental features on an ember canary build - // e.g. 'with-controller': true - } - }, - - APP: { - // Here you can pass flags/options to your application instance - // when it is created - } - }; - - if (environment === 'development') { - // ENV.APP.LOG_RESOLVER = true; - ENV.APP.LOG_ACTIVE_GENERATION = true; - // ENV.APP.LOG_TRANSITIONS = true; - // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; - ENV.APP.LOG_VIEW_LOOKUPS = true; - } - - if (environment === 'test') { - - } - - if (environment === 'production') { - - } - - return ENV; -}; diff --git a/blueprints/app/files/config/production.js b/blueprints/app/files/config/production.js new file mode 100644 index 0000000000..913f594e97 --- /dev/null +++ b/blueprints/app/files/config/production.js @@ -0,0 +1,30 @@ +/* jshint node: true */ + +module.exports = function(config) { + config.set('production', true); + config.set('hinting', false); + config.set('tests', process.env.EMBER_CLI_TEST_COMMAND || false); + + config.set('es3Safe', true); + config.set('wrapInEval', false); + config.set('minify', { + css: { + relativeTo: 'app/styles' + }, + js: { + mangle: true, + compress: true + } + }); + + config.set('ENV', { + baseURL: '/', + locationType: 'auto', + EmberENV: { + FEATURES: { + // Here you can enable experimental features on an ember canary build + // e.g. 'with-controller': true + } + } + }); +}; diff --git a/blueprints/app/files/config/test.js b/blueprints/app/files/config/test.js new file mode 100644 index 0000000000..832b564d45 --- /dev/null +++ b/blueprints/app/files/config/test.js @@ -0,0 +1,8 @@ +/* jshint node: true */ + +var productionConfig = require('./production.js'); + +module.exports = function(config) { + productionConfig(config); + config.set('tests', true); +}; diff --git a/lib/broccoli/ember-app.js b/lib/broccoli/ember-app.js index bfd1a70bba..d775395f32 100644 --- a/lib/broccoli/ember-app.js +++ b/lib/broccoli/ember-app.js @@ -6,7 +6,6 @@ var p = require('../preprocessors'); var chalk = require('chalk'); var Project = require('../models/project'); -var Config = require('../models/config'); var cleanBaseURL = require('../utilities/clean-base-url'); var preprocessJs = p.preprocessJs; @@ -375,7 +374,6 @@ EmberApp.prototype.javascript = memoize(function() { var vendorAndApp = mergeTrees([vendor, es6]); - var config = this.project.config(this.env); if (config.isEnabled('minify', 'js')) { var options = config.get('minify', 'js') || {}; return uglifyJavaScript(vendorAndApp, options); diff --git a/lib/models/config.js b/lib/models/config.js index e0899d4d1e..005950e000 100644 --- a/lib/models/config.js +++ b/lib/models/config.js @@ -1,7 +1,6 @@ 'use strict'; var isObject = require('lodash-node/modern/objects/isObject'); -var isArray = require('lodash-node/modern/objects/isArray'); var isUndefined = require('lodash-node/modern/objects/isUndefined'); var defaults = require('lodash-node/modern/objects/defaults'); var merge = require('lodash-node/modern/objects/merge'); @@ -27,7 +26,7 @@ Config.prototype.get = function(group, key) { return this.get(group); } } -} +}; // setter Config.prototype.set = function(group) { @@ -45,16 +44,16 @@ Config.prototype.set = function(group) { } this.options[group] = merge(newOptions, this.options[group], defaults); -} +}; Config.prototype.isEnabled = function() { return !!this.get.apply(this, arguments); -} +}; Config.prototype.debug = function() { console.log('groupOptions: ', this.groupOptions); console.log('options: ', this.options); -} +}; Config.prototype.push = function (group, key, option) { if(isUndefined(this.options[group]) || isUndefined(this.options[group][key])) { @@ -63,7 +62,7 @@ Config.prototype.push = function (group, key, option) { } this.options[group][key].push(option); -} +}; -module.exports = Config; \ No newline at end of file +module.exports = Config; diff --git a/tests/fixtures/brocfile-tests/wrap-in-eval/Brocfile.js b/tests/fixtures/brocfile-tests/wrap-in-eval/Brocfile.js index 009c3e53d2..6682ecf036 100644 --- a/tests/fixtures/brocfile-tests/wrap-in-eval/Brocfile.js +++ b/tests/fixtures/brocfile-tests/wrap-in-eval/Brocfile.js @@ -5,9 +5,7 @@ var EmberApp = require('ember-cli/lib/broccoli/ember-app'); var app = new EmberApp({ name: require('./package.json').name, - wrapInEval: true, - - getEnvJSON: require('./config/environment') + wrapInEval: true }); module.exports = app.toTree(); diff --git a/tests/helpers/mock-project.js b/tests/helpers/mock-project.js index 44d09eb920..f91c1ac9e8 100644 --- a/tests/helpers/mock-project.js +++ b/tests/helpers/mock-project.js @@ -9,7 +9,7 @@ function MockProject() { } MockProject.prototype.require = function(file) { - if (file === './config/environment') { + if (file === './config/test') { return function() { return function() { return { baseURL: '/' }; diff --git a/tests/unit/models/project-test.js b/tests/unit/models/project-test.js index f2b0ad724f..6b04fc2793 100644 --- a/tests/unit/models/project-test.js +++ b/tests/unit/models/project-test.js @@ -19,7 +19,7 @@ describe('models/project.js', function() { before(function() { tmp.setup(projectPath); - touch(projectPath + '/config/environment.js', { + touch(projectPath + '/config/test.js', { baseURL: '/foo/bar' }); @@ -35,8 +35,8 @@ describe('models/project.js', function() { tmp.teardown(projectPath); }); - it('config() finds and requires config/environment', function() { - project.config('development'); + it('config() finds and requires config/test', function() { + project.config('test'); assert.equal(called, true); }); }); From 4d28f8373914e828fdfe1ac964d90098fa3888ec Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Tue, 29 Jul 2014 20:18:58 +0200 Subject: [PATCH 04/10] Moar test fixyfix --- blueprints/app/files/config/development.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/blueprints/app/files/config/development.js b/blueprints/app/files/config/development.js index 5f2622c324..3d9976f448 100644 --- a/blueprints/app/files/config/development.js +++ b/blueprints/app/files/config/development.js @@ -7,9 +7,6 @@ module.exports = function(config) { config.set('production', false); config.set('tests', true); - config.set('hinting', true, { - js - }); config.set('wrapInEval', true); From 6ef805fd9fa863bac33e6265a6ba3b5365753a81 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 14 Aug 2014 11:56:46 +0200 Subject: [PATCH 05/10] Cleanup --- lib/models/config.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/models/config.js b/lib/models/config.js index 005950e000..6e5da4f3cf 100644 --- a/lib/models/config.js +++ b/lib/models/config.js @@ -1,20 +1,20 @@ 'use strict'; var isObject = require('lodash-node/modern/objects/isObject'); -var isUndefined = require('lodash-node/modern/objects/isUndefined'); +var isUndefined = require('lodash-node/modern/objects/isUndefined'); var defaults = require('lodash-node/modern/objects/defaults'); var merge = require('lodash-node/modern/objects/merge'); function Config() { - this.options = {}; - this.groupOptions = {}; + this.options = Object.create(null); + this.groupOptions = Object.create(null); } // getter Config.prototype.get = function(group, key) { - var argc = arguments.length, - options = this.options; + var argc = arguments.length; + var options = this.options; if (argc === 1) { // group getter @@ -50,11 +50,6 @@ Config.prototype.isEnabled = function() { return !!this.get.apply(this, arguments); }; -Config.prototype.debug = function() { - console.log('groupOptions: ', this.groupOptions); - console.log('options: ', this.options); -}; - Config.prototype.push = function (group, key, option) { if(isUndefined(this.options[group]) || isUndefined(this.options[group][key])) { this.options[group] = this.options[group] || {}; From d1e6394bbbcb0e97a0e93ff4effb88d5d1fd10c7 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 14 Aug 2014 12:05:14 +0200 Subject: [PATCH 06/10] Cache config object in app for now --- lib/broccoli/ember-app.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/broccoli/ember-app.js b/lib/broccoli/ember-app.js index d775395f32..6a06acb2fc 100644 --- a/lib/broccoli/ember-app.js +++ b/lib/broccoli/ember-app.js @@ -56,8 +56,10 @@ function EmberApp(options) { this.env = process.env.EMBER_ENV || 'development'; + this.config = this.project.config(this.env); + this.getEnvJSON = function () { - return this.project.config(this.env).get('ENV'); + return this.config.get('ENV'); }.bind(this); this.options = merge(options, { @@ -275,8 +277,7 @@ EmberApp.prototype.appAndDependencies = memoize(function() { var app = this._processedAppTree(); var templates = this._processedTemplatesTree(); - var config = this.project.config(this.env); - if (config.isEnabled('es3Safe')) { + if (this.config.isEnabled('es3Safe')) { app = new ES3SafeFilter(app); } @@ -333,9 +334,8 @@ EmberApp.prototype.appAndDependencies = memoize(function() { EmberApp.prototype.javascript = memoize(function() { var applicationJs = this.appAndDependencies(); var legacyFilesToAppend = this.legacyFilesToAppend; - var config = this.project.config(this.env); - if (config.isEnabled('tests')) { + if (this.config.isEnabled('tests')) { this.import('vendor/ember-qunit/dist/named-amd/main.js', { exports: { 'ember-qunit': [ @@ -404,8 +404,7 @@ EmberApp.prototype.styles = memoize(function() { description: 'concatFiles - vendorStyles' }); - var config = this.project.config(this.env); - if (config.isEnabled('minify', 'css')) { + if (this.config.isEnabled('minify', 'css')) { var options = config.get('minify', 'css') || {}; processedStyles = preprocessMinifyCss(processedStyles, options); vendorStyles = preprocessMinifyCss(vendorStyles, options); @@ -441,8 +440,7 @@ EmberApp.prototype.testFiles = memoize(function() { destDir: '/' }); - var config = this.project.config(this.env); - if (config.isEnabled('fingerprint')) { + if (this.config.isEnabled('fingerprint')) { config.push('fingerprint', 'exclude', 'testem'); } @@ -569,8 +567,7 @@ EmberApp.prototype.toArray = function() { sourceTrees.push(publicFolder); } - var config = this.project.config(this.env); - if (config.isEnabled('tests')) { + if (this.config.isEnabled('tests')) { sourceTrees = sourceTrees.concat(this.testIndex(), this.testFiles()); } From db15507f784603b3de0006bb2529ad83ac1b9da1 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 14 Aug 2014 12:19:38 +0200 Subject: [PATCH 07/10] Fixy fix --- lib/broccoli/ember-app.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/broccoli/ember-app.js b/lib/broccoli/ember-app.js index 6a06acb2fc..355e74172b 100644 --- a/lib/broccoli/ember-app.js +++ b/lib/broccoli/ember-app.js @@ -286,19 +286,19 @@ EmberApp.prototype.appAndDependencies = memoize(function() { var sourceTrees = [ vendor, preprocessedApp, templates ]; - if (config.isEnabled('tests')) { + if (this.config.isEnabled('tests')) { var tests = this._processedTestsTree(); var preprocessedTests = preprocessJs(tests, '/tests', this.name); sourceTrees.push(preprocessedTests); - if (config.isEnabled('hinting', 'js')) { + if (this.config.isEnabled('hinting', 'js')) { var jshintedApp = jshintTrees(preprocessedApp, { - jshintrcPath: config.get('hinting', 'js', 'app') || this.project.root, + jshintrcPath: this.config.get('hinting', 'js', 'app') || this.project.root, description: 'JSHint - App' }); var jshintedTests = jshintTrees(tests, { - jshintrcPath: config.get('hinting', 'js', 'tests') || path.join(this.project.root, 'tests'), + jshintrcPath: this.config.get('hinting', 'js', 'tests') || path.join(this.project.root, 'tests'), description: 'JSHint - Tests' }); @@ -374,8 +374,8 @@ EmberApp.prototype.javascript = memoize(function() { var vendorAndApp = mergeTrees([vendor, es6]); - if (config.isEnabled('minify', 'js')) { - var options = config.get('minify', 'js') || {}; + if (this.config.isEnabled('minify', 'js')) { + var options = this.config.get('minify', 'js') || {}; return uglifyJavaScript(vendorAndApp, options); } else { return vendorAndApp; @@ -405,7 +405,7 @@ EmberApp.prototype.styles = memoize(function() { }); if (this.config.isEnabled('minify', 'css')) { - var options = config.get('minify', 'css') || {}; + var options = this.config.get('minify', 'css') || {}; processedStyles = preprocessMinifyCss(processedStyles, options); vendorStyles = preprocessMinifyCss(vendorStyles, options); } From e3ef955c6743d57e39e80b3dcc9d9bca3f9c4a8a Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 14 Aug 2014 12:21:15 +0200 Subject: [PATCH 08/10] Fooo --- lib/broccoli/ember-app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/broccoli/ember-app.js b/lib/broccoli/ember-app.js index 355e74172b..7e9035d505 100644 --- a/lib/broccoli/ember-app.js +++ b/lib/broccoli/ember-app.js @@ -441,7 +441,7 @@ EmberApp.prototype.testFiles = memoize(function() { }); if (this.config.isEnabled('fingerprint')) { - config.push('fingerprint', 'exclude', 'testem'); + this.config.push('fingerprint', 'exclude', 'testem'); } var iconsTree = pickFiles(this.trees.vendor, { From 85c148feafac69ff8c8e92dae7bc1bc90817d6aa Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 14 Aug 2014 13:22:54 +0200 Subject: [PATCH 09/10] Return empty config object if config file is not found instead of empty object --- lib/models/project.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/models/project.js b/lib/models/project.js index 5110f39117..3ec96bf5f3 100644 --- a/lib/models/project.js +++ b/lib/models/project.js @@ -43,13 +43,11 @@ Project.prototype.config = function(env) { requirePath = './config/' + env; } + var config = new Config(); if (fs.existsSync(configPath)) { - var config = new Config(); this.require(requirePath)(config); - return config; - } else { - return { }; } + return config; }; Project.prototype.has = function(file) { From 6fc306c1d7bcd5925a688c2f5278d6b4f6c46f5d Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 14 Aug 2014 18:00:56 +0200 Subject: [PATCH 10/10] foo --- lib/models/project.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/models/project.js b/lib/models/project.js index 3ec96bf5f3..3dee8fc7a0 100644 --- a/lib/models/project.js +++ b/lib/models/project.js @@ -33,19 +33,15 @@ Project.prototype.isEmberCLIAddon = function() { Project.prototype.config = function(env) { - var configPath, requirePath; + var configPath = 'config'; if (this.pkg['ember-addon'] && this.pkg['ember-addon']['configPath']) { configPath = this.pkg['ember-addon']['configPath']; - requirePath = './' + path.join(configPath, 'environment'); - } else { - configPath = path.join(this.root, 'config', env + '.js'); - requirePath = './config/' + env; } var config = new Config(); - if (fs.existsSync(configPath)) { - this.require(requirePath)(config); + if (fs.existsSync(path.join(this.root, configPath, env + '.js'))) { + this.require('./' + path.join(configPath, env))(config); } return config; };