Skip to content

Commit

Permalink
Merge pull request #693 from rjackson/do-not-watch-vendor
Browse files Browse the repository at this point in the history
Do not watch vendor/ for changes.
  • Loading branch information
stefanpenner committed May 12, 2014
2 parents fda4079 + 48d132e commit 133c658
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
test. A new app is generated, depedencies resolve, and the test for
that base app are run. [#614](https://github.com/stefanpenner/ember-cli/pull/614)
* [ENHANCEMENT] Use handlebars-runtime in production. [#675](https://github.com/stefanpenner/ember-cli/pull/675)
* [BUGFIX] Do not watch `vendor/` for changes (watching vendor drammatically increases CPU usage). [#693](https://github.com/stefanpenner/ember-cli/pull/693)

### 0.0.27

Expand Down
18 changes: 16 additions & 2 deletions lib/broccoli/ember-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var mergeTrees = require('broccoli-merge-trees');
var jshintTrees = require('broccoli-jshint');
var concatFiles = require('broccoli-concat');

var unwatchedTree = require('broccoli-unwatched-tree');
var uglifyJavaScript = require('broccoli-uglify-js');

var memoize = require('lodash-node/modern/functions').memoize;
Expand Down Expand Up @@ -46,12 +47,13 @@ function EmberApp(options) {
app: 'app',
styles: 'app/styles',
tests: 'tests',
vendor: 'vendor',
vendor: unwatchedTree('vendor'),
});

this.importWhitelist = {};
this.legacyFilesToAppend = [];
this.vendorStaticStyles = [];
this._importTrees = [];

this.trees = this.options.trees;

Expand Down Expand Up @@ -123,7 +125,11 @@ EmberApp.prototype._processedAppTree = memoize(function() {
});

EmberApp.prototype._processedVendorTree = memoize(function() {
return pickFiles(this.trees.vendor, {
var mergedVendor = mergeTrees([this.trees.vendor].concat(this._importTrees), {
overwrite: true
});

return pickFiles(mergedVendor, {
srcDir: '/',
destDir: 'vendor/'
});
Expand Down Expand Up @@ -264,12 +270,20 @@ EmberApp.prototype.import = function(asset, modules) {
assetPath = asset;
}

var directory = path.dirname(assetPath);
var extension = path.extname(assetPath);

if (!extension) {
throw new Error('You must pass a file to `EmberApp::import`. For directories specify them to the constructor under the `trees` option.');
}

var assetTree = pickFiles(directory, {
srcDir: '/',
destDir: directory.replace(/^vendor\//, '')
});

this._importTrees.push(assetTree);

if (isType(assetPath, 'js')) {
this.legacyFilesToAppend.push(assetPath);

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
"diff": "~1.0.8",
"broccoli-concat": "0.0.6",
"broccoli-file-mover": "~0.3.1",
"connect-chain": "0.0.1"
"connect-chain": "0.0.1",
"broccoli-unwatched-tree": "~0.1.1"
},
"devDependencies": {
"chai": "^1.9.1",
Expand Down

0 comments on commit 133c658

Please sign in to comment.