Permalink
Browse files

Remove minimatch dependency, delay loading uglify, update readme

  • Loading branch information...
1 parent e760ac7 commit df302b1992034b24e22c791f30920efc90eddf86 @arobson arobson committed Dec 20, 2012
Showing with 34 additions and 27 deletions.
  1. +4 −0 .npmignore
  2. +3 −3 README.md
  3. +13 −11 lib/uglify.js
  4. +3 −4 package.json
  5. +11 −9 src/uglify.js
View
@@ -0,0 +1,4 @@
+node_modules
+header.js
+src
+.anvil
View
@@ -1,14 +1,14 @@
-## Anvil Uglify Plugin
+## Anvil Uglify Extension
-This plugin requires anvil.js version 0.8.* or greater.
+This extension requires anvil.js version 0.9.* or greater.
## Installation
anvil install anvil.uglify
## Usage
-If this plugin is installed and enabled, it will automatically minify .js files using the uglify-js node library.
+If this extension is installed and enabled, it will automatically minify .js files using the uglify-js node library.
### Minifying All The Things
Add the following snippet to the build.json:
View
@@ -1,19 +1,18 @@
/*
- anvil.uglify - Uglify plugin for anvil.js
- version: 0.0.10
+ anvil.uglify - Uglify extension for anvil.js
+ version: 0.1.0
author: Alex Robson <alex@sharplearningcurve.com> (http://sharplearningcurve.com)
copyright: 2011 - 2012
license: Dual licensed
MIT (http://www.opensource.org/licenses/mit-license)
GPL (http://www.opensource.org/licenses/gpl-license)
*/
-var jsp = require( "uglify-js" ).parser,
- pro = require( "uglify-js" ).uglify,
- minimatch = require( "minimatch" ),
+var jsp,
+ pro,
path = require( "path" );
-var uglifyFactory = function( _, anvil ) {
- return anvil.plugin( {
+module.exports = function( _, anvil ) {
+ anvil.plugin( {
name: "anvil.uglify",
activity: "post-process",
all: false,
@@ -49,6 +48,11 @@ var uglifyFactory = function( _, anvil ) {
return;
}
+ if ( !jsp || !pro ) {
+ jsp = require( "uglify-js" ).parser;
+ pro = require( "uglify-js" ).uglify;
+ }
+
var self = this,
getRegex = function( sep ) { return anvil.utility.parseRegex( "/[\\" + sep + "]/g" ); },
osSep = path.sep,
@@ -68,7 +72,7 @@ var uglifyFactory = function( _, anvil ) {
any = function( file ) {
return _.any( specs, function( spec ) {
return file === spec ||
- minimatch.match( [ file ], spec.replace( /^.[\/]/, "/" ), {} ).length > 0;
+ anvil.fs.match( [ file ], spec.replace( /^.[\/]/, "/" ), {} ).length > 0;
} );
},
getPath = function( file ) {
@@ -151,6 +155,4 @@ var uglifyFactory = function( _, anvil ) {
}
}
} );
-};
-
-module.exports = uglifyFactory;
+};
View
@@ -1,8 +1,8 @@
{
"author": "Alex Robson <alex@sharplearningcurve.com> (http://sharplearningcurve.com)",
"name": "anvil.uglify",
- "description": "Uglify plugin for anvil.js",
- "version": "0.0.10",
+ "description": "Uglify extension for anvil.js",
+ "version": "0.1.0",
"repository": {
"type": "git",
"url": "git://github.com/arobson/anvil.uglify.git"
@@ -12,8 +12,7 @@
},
"main": "./lib/uglify.js",
"dependencies": {
- "uglify-js": "~1.3.3",
- "minimatch": "~0.2.6"
+ "uglify-js": "~1.3.3"
},
"devDependencies": {
"should": "~1.1"
View
@@ -1,10 +1,9 @@
-var jsp = require( "uglify-js" ).parser,
- pro = require( "uglify-js" ).uglify,
- minimatch = require( "minimatch" ),
+var jsp,
+ pro,
path = require( "path" );
-var uglifyFactory = function( _, anvil ) {
- return anvil.plugin( {
+module.exports = function( _, anvil ) {
+ anvil.plugin( {
name: "anvil.uglify",
activity: "post-process",
all: false,
@@ -40,6 +39,11 @@ var uglifyFactory = function( _, anvil ) {
return;
}
+ if ( !jsp || !pro ) {
+ jsp = require( "uglify-js" ).parser;
+ pro = require( "uglify-js" ).uglify;
+ }
+
var self = this,
getRegex = function( sep ) { return anvil.utility.parseRegex( "/[\\" + sep + "]/g" ); },
osSep = path.sep,
@@ -59,7 +63,7 @@ var uglifyFactory = function( _, anvil ) {
any = function( file ) {
return _.any( specs, function( spec ) {
return file === spec ||
- minimatch.match( [ file ], spec.replace( /^.[\/]/, "/" ), {} ).length > 0;
+ anvil.fs.match( [ file ], spec.replace( /^.[\/]/, "/" ), {} ).length > 0;
} );
},
getPath = function( file ) {
@@ -142,6 +146,4 @@ var uglifyFactory = function( _, anvil ) {
}
}
} );
-};
-
-module.exports = uglifyFactory;
+};

0 comments on commit df302b1

Please sign in to comment.