ember-cli-node-assets
Advanced tools
Comparing version 0.1.0 to 0.1.1
31
index.js
@@ -6,5 +6,9 @@ /* jshint node: true */ | ||
var resolve = require('resolve'); | ||
var clone = require('clone'); | ||
var debug = require('debug')('ember-cli-node-assets'); | ||
var clone = require('lodash/clone'); | ||
var pick = require('lodash/pick'); | ||
var map = require('lodash/map'); | ||
var omit = require('lodash/omit'); | ||
var Funnel = require('broccoli-funnel'); | ||
@@ -28,6 +32,7 @@ var UnwatchedTree = require('broccoli-unwatched-tree'); | ||
if (!mod.import) return; | ||
mod.import.include.forEach(function(file) { | ||
var fullPath = path.join('vendor', mod.import.destDir, file); | ||
debug('importing %s', fullPath); | ||
app.import(fullPath); | ||
mod.import.include.forEach(function(item) { | ||
var fullPath = path.join('vendor', mod.import.destDir, item.path); | ||
var options = omit(item, 'path'); | ||
debug('importing %s with options %o', fullPath, options); | ||
app.import(fullPath, options); | ||
}); | ||
@@ -63,3 +68,6 @@ }); | ||
if ('enabled' in moduleOptions && !moduleOptions.enabled) { return; } | ||
if ('enabled' in moduleOptions && !moduleOptions.enabled) { | ||
debug('skipping disabled module %s', name); | ||
return; | ||
} | ||
@@ -84,2 +92,6 @@ return { | ||
normalized.include = normalized.include.map(function(item) { | ||
return typeof item === 'string' ? { path: item } : item; | ||
}); | ||
if (options.srcDir && !normalized.srcDir) { | ||
@@ -117,4 +129,7 @@ normalized.srcDir = options.srcDir; | ||
var root = path.dirname(resolve.sync(name + '/package.json', { basedir: parent.root })); | ||
debug('adding tree for %s at %s %o', name, root, options); | ||
return new Funnel(new UnwatchedTree(root), options); | ||
var funnelOptions = pick(options, 'srcDir', 'destDir', 'include', 'exclude'); | ||
funnelOptions.include = map(funnelOptions.include, 'path'); | ||
debug('adding tree for %s at %s %o', name, root, funnelOptions); | ||
return new Funnel(new UnwatchedTree(root), funnelOptions); | ||
} |
{ | ||
"name": "ember-cli-node-assets", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Include CSS, images and other assets in your app or addon directly from node modules", | ||
@@ -45,4 +45,4 @@ "directories": { | ||
"broccoli-unwatched-tree": "^0.1.1", | ||
"clone": "^1.0.2", | ||
"debug": "^2.2.0", | ||
"lodash": "^4.5.1", | ||
"resolve": "^1.1.7" | ||
@@ -49,0 +49,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
# ember-cli-node-assets | ||
# ember-cli-node-assets [![Build Status](https://travis-ci.org/dfreeman/ember-cli-node-assets.svg?branch=master)](https://travis-ci.org/dfreeman/ember-cli-node-assets) | ||
@@ -63,3 +63,5 @@ Incorporate stylesheets, images, globals-style scripts and other assets directly from node modules into your Ember app or addon. | ||
- `include`: an array of strings representing the paths to files that should be imported and concatenated into `vendor.js` or `vendor.css` | ||
- `include`: an array of files that should be imported and concatenated into the served JS or CSS files. Each file may be: | ||
- a string representing the path to file that should be imported | ||
- a hash containing a `path` key with the path to the file, as well as any other options to be specified to [`app.import`](http://ember-cli.com/user-guide/), like `type: 'test'` or `prepend: true` | ||
- `srcDir` (optional): the source directory (relative to the module's directory) from which files should be included | ||
@@ -66,0 +68,0 @@ - `processTree` (optional): a function to perform any necessary processing on the Broccoli tree containing the given files before they are imported |
10735
110
98
+ Addedlodash@^4.5.1
+ Addedlodash@4.17.21(transitive)
- Removedclone@^1.0.2
- Removedclone@1.0.4(transitive)