diff options
Diffstat (limited to 'hooks/before_prepare')
| -rwxr-xr-x | hooks/before_prepare/01_pp_hacks.sh | 62 | ||||
| -rwxr-xr-x | hooks/before_prepare/02_jshint.js | 73 |
2 files changed, 135 insertions, 0 deletions
diff --git a/hooks/before_prepare/01_pp_hacks.sh b/hooks/before_prepare/01_pp_hacks.sh new file mode 100755 index 00000000..d049f8e7 --- /dev/null +++ b/hooks/before_prepare/01_pp_hacks.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +exe() { echo "\$ $@" ; "$@" ; } + +# Custom stuff I need to do for zmNinja +echo ---------------------------------------------------- +echo Pliable Pixels build pre-preprocessing +echo ---------------------------------------------------- +echo Curr Dir: `pwd` + +#if [ -d "plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/" ]; then +# echo "Copying Modified GCMIntentService for custom sound" +# exe cp www/external/GCMIntentService.java plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/ +# exe cp www/external/GCMIntentService.java platforms/android/src/com/adobe/phonegap/push +#else +# echo "Directory plugins/phonegap-plugin-push/src/android/com/adobe/phonegap/push/ does not exist, skipping..." +#fi + +echo "Copying custom sound" +echo "---------------------" + +if [ -d "platforms/android" ]; then + exe mkdir -p platforms/android/res/raw/ + exe cp www/sounds/blop.mp3 platforms/android/res/raw/ + exe cp www/sounds/blop.caf platforms/ios/zmNinja/Resources +else + echo "Directory platforms/android does not exist, skipping..." +fi + +#echo "Copying plist hack for iOS for non SSL connections" +#echo "--------------------------------------------------" +#if [ -d "platforms/ios/zmNinja" ]; then +# exe cp www/external/zmNinja-Info.plist.IOS9nonSSLPatch platforms/ios/zmNinja/zmNinja-Info.plist +#else +# echo "Directory platforms/ios/zmNinja does not exist, skipping..." +#fi + +echo "Copying Android notification icons to resource dir" +echo "--------------------------------------------------" +if [ -d "platforms/android/res/" ]; then + exe cp -R www/external/android-notification-icons/ platforms/android/res/ +else + echo "Directory platforms/android/res/ does not exist, skipping..." +fi + +#echo "Fixing insecure SSL permission problem" +#echo "--------------------------------------------------" +#if [ -d "platforms/android/CordovaLib/src/org/apache/cordova/engine" ]; then +# exe cp www/external/SystemWebViewClient.java platforms/android/CordovaLib/src/org/apache/cordova/engine +#else +# echo "Directory platforms/android/CordovaLib/src/org/apache/cordova/engine does not exist, skipping..." +#fi +#if [ -d "platforms/ios/zmNinja/Classes" ]; then +# exe cp www/external/AppDelegate.m platforms/ios/zmNinja/Classes/ +#else +# echo "Directory platforms/ios/zmNinja/Classes does not exist, skipping..." +#fi + + + + + diff --git a/hooks/before_prepare/02_jshint.js b/hooks/before_prepare/02_jshint.js new file mode 100755 index 00000000..fff7775d --- /dev/null +++ b/hooks/before_prepare/02_jshint.js @@ -0,0 +1,73 @@ +#!/usr/bin/env node + +var fs = require('fs'); +var path = require('path'); +var jshint = require('jshint').JSHINT; +var async = require('async'); + +var foldersToProcess = [ + 'js' +]; + +foldersToProcess.forEach(function(folder) { + processFiles("www/" + folder); +}); + +function processFiles(dir, callback) { + var errorCount = 0; + fs.readdir(dir, function(err, list) { + if (err) { + console.log('processFiles err: ' + err); + return; + } + async.eachSeries(list, function(file, innercallback) { + file = dir + '/' + file; + fs.stat(file, function(err, stat) { + if(!stat.isDirectory()) { + if(path.extname(file) === ".js") { + lintFile(file, function(hasError) { + if(hasError) { + errorCount++; + } + innercallback(); + }); + } else { + innercallback(); + } + } else { + innercallback(); + } + }); + }, function(error) { + if(errorCount > 0) { + process.exit(1); + } + }); + }); +} + +function lintFile(file, callback) { + console.log("Linting " + file); + fs.readFile(file, function(err, data) { + if(err) { + console.log('Error: ' + err); + return; + } + if(jshint(data.toString())) { + console.log('File ' + file + ' has no errors.'); + console.log('-----------------------------------------'); + callback(false); + } else { + console.log('Errors in file ' + file); + var out = jshint.data(), + errors = out.errors; + for(var j = 0; j < errors.length; j++) { + console.log(errors[j].line + ':' + errors[j].character + ' -> ' + errors[j].reason + ' -> ' + +errors[j].evidence); + } + console.log('-----------------------------------------'); + callback(true); + } + }); +} + |
