Skip to content
Browse files

Merge branch 'feature/bundler'

  • Loading branch information...
2 parents cdba667 + e92b114 commit ff2b5d301de30fcb607e97bdbabbeb69cbbb41b3 @tj tj committed May 10, 2011
Showing with 55 additions and 2 deletions.
  1. +1 −0 .npmignore
  2. +30 −0 Readme.md
  3. +24 −2 bin/asset
View
1 .npmignore
@@ -1,3 +1,4 @@
support
test
examples
+public
View
30 Readme.md
@@ -16,6 +16,7 @@
install <name ...> installs the given asset <name ...>
search [query] search available assets with optional [query]
info <name ...> display verbose information for the given asset <name ...>
+ none install dependencies from ./assets.json
Options:
@@ -136,6 +137,35 @@
download : raphael@1.4.7
complete : raphael@1.4.7 public/raphael.js
+### assets.json
+
+ By adding `./assets.json` you can store application dependencies, and install them quickly and easily with a single command `asset`. For example this file may contain one or more deps:
+
+ {
+ "g.raphael": "0.4.1"
+ , "jquery": "1.5.2"
+ , "modernizr": "1.7"
+ }
+
+
+ Installed with the command:
+
+ $ asset
+
+ install : g.raphael@0.4.1
+ dependency : raphael@1.4.7
+ install : raphael@1.4.7
+ install : jquery@1.5.2
+ install : modernizr@1.7
+ download : jquery@1.5.2
+ complete : jquery@1.5.2 public/jquery.js
+ download : raphael@1.4.7
+ complete : raphael@1.4.7 public/raphael.js
+ download : g.raphael@0.4.1
+ complete : g.raphael@0.4.1 public/g.raphael.js
+ download : modernizr@1.7
+ complete : modernizr@1.7 public/modernizr.js
+
### Configuration
By default options must be passed via the CLI, however `asset` will also check the `./.asset` and `~/.asset` JSON configuration files, so for example a project may set `{ "out": "public/javascripts" }` if we are mainly working with javascript, however the CLI options will always take precedence.
View
26 bin/asset
@@ -43,6 +43,7 @@ var usage = [
, ' install <name ...> installs the given asset <name ...>'
, ' search [query] search available assets with optional [query]'
, ' info <name ...> display verbose information for the given asset <name ...>'
+ , ' none install dependencies from ./assets.json'
, ''
, ' Options:'
, ''
@@ -126,7 +127,15 @@ while (args.length) {
}
}
-// no assets given
+// parse the asset strings or ./assets.json
+
+if (assets.length) {
+ assets = assets.map(parse);
+} else {
+ assets = assetsFromObject(readJSON('assets.json'));
+}
+
+// ensure we have assets
if (!assets.length) abort('asset <name ...> required');
@@ -140,13 +149,26 @@ mkdir(options.out, function(err){
process.on('exit', function(){ console.log(); });
/**
+ * Install assets from JSON `obj`.
+ *
+ * @param {Object} obj
+ */
+
+function assetsFromObject(obj) {
+ var arr = [];
+ for (var asset in obj) {
+ arr.push({ name: asset, version: obj[asset] });
+ }
+ return arr;
+}
+
+/**
* Install the given `assets`.
*
* @param {Array} assets
*/
function install(assets) {
- assets = assets.map(parse);
var install = asset.install(assets, repo, options.out);
install.on('unknown', function(asset){

0 comments on commit ff2b5d3

Please sign in to comment.
Something went wrong with that request. Please try again.