-
-
Save johnbender/3a4898465e4c0a9092eb to your computer and use it in GitHub Desktop.
Determine jQuery method dependencies.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# assumes pwd == /path/to/core/project/dir | |
for method in `cat ../mobile/debug/uniq-methods`; do | |
grep -lR "$method:" src >> /tmp/core-method-list; | |
done | |
# exclude sizzle since we're sure we'll need it | |
cat /tmp/core-method-list.log | grep -v 'sizzle' | sort | uniq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# assumes pwd == /path/to/jqm/project/dir | |
node node_modules/.bin/grunt test > /tmp/method-log-output | |
grep "METHOD USED" /tmp/method-log-output | sed 's/.*METHOD USED: //' | sort | uniq | > /tmp/uniq-methods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// After jQuery/QUnit but before tests run | |
// complete crap but it works | |
window.methodList = { | |
new: {}, | |
old: {} | |
}; | |
function redefineProp( prop ){ | |
var original = jQuery.fn[prop]; | |
return function(){ | |
// if we haven't seen it this page load | |
// make note of it | |
if( !window.methodList.old[prop] ){ | |
window.methodList.new[prop] = true; | |
} | |
// keep track for subsequent calls | |
window.methodList.old[prop] = true; | |
return original.apply(this, arguments); | |
}; | |
} | |
for(prop in jQuery.fn) { | |
if( jQuery.fn.hasOwnProperty( prop ) && | |
typeof jQuery.fn[ prop ] == "function" && | |
prop !== "init" ) { | |
jQuery.fn[prop] = redefineProp(prop); | |
} | |
} | |
// NOTE with qunit and phantom QUnit.done appears to be bound after the | |
// grunt-qunit binding which moves the suite on to the next set of tests | |
$(function() { | |
console.log( "" ); | |
QUnit.testDone(function() { | |
console.log( "" ); | |
// print only the new stuff | |
for( method in window.methodList.new ) { | |
console.log( "METHOD USED: " + method ); | |
} | |
window.methodList.new = {}; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment