Permalink
Browse files

Only files that include functions that are being stripped (if any) ar…

…e parsed by burrito. v0.2.1
  • Loading branch information...
1 parent 61cc1b6 commit 09bb149424de70b00e7e2ce684a9c11e286f33e4 @chrisjpowers committed Jul 8, 2012
Showing with 7 additions and 5 deletions.
  1. +5 −3 lib/air-drop.js
  2. +1 −1 package.json
  3. +1 −1 spec/air-drop-spec.coffee
View
@@ -240,10 +240,12 @@ var packageMethods = {
_stripFunctions: function(code) {
var nodeName, i,
burrito = require('burrito'),
- package = this;
+ package = this,
+ includesStrippedFunction = false;
- //do not burrito if no functionsToStrip (burrito jquery take more than 15 seconds on my laptop)
- if (this.functionsToStrip.length == 0) return code;
+ // Only use burrito to parse the code if at least one of the functionsToStrip is present in the code.
+ includesStrippedFunction = _(package.functionsToStrip).detect(function(s) { return code.indexOf(s) > -1; });
+ if (!includesStrippedFunction) return code;
return burrito(code, function (node) {
if (node.name === 'call') {
View
@@ -1,6 +1,6 @@
{
"name": "air-drop",
- "version": "0.2.0",
+ "version": "0.2.1",
"author": "Chris Powers <chrisjpowers@gmail.com>",
"description": "Utility for packaging, manipulating and delivering JS and CSS source to the browser",
"scripts": {
@@ -231,7 +231,7 @@ describe "AirDrop", ->
.stripFunction("stripThis")
.package()
- it "mangles and squeezes output", ->
+ it "removes the stripped function", ->
expectSourceToMatchFile drop, "#{__dirname}/fixtures/stripping/stripped.js"

0 comments on commit 09bb149

Please sign in to comment.