Created
February 27, 2015 20:54
-
-
Save sgdavis1/bbeb84efba13eee6fc47 to your computer and use it in GitHub Desktop.
hooks/before_build/010_check_cordovalib.js
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
#!/usr/bin/env node | |
// This hook ensures no one has accidentally deleted the "cordova" script tag | |
var fs = require('fs'); | |
var path = require('path'); | |
var sys = require('sys') | |
var rootdir = process.argv[2]; | |
var config = fs.readFileSync(path.join(rootdir, 'config.xml')); | |
var content = ""; | |
if (matches = /<content\s+src=['"](\S+)['"]/.exec(config)) | |
{ | |
sys.puts(' Looking for script tag to "cordova.js" in: ' + matches[1]); | |
content = fs.readFileSync(path.join(rootdir, "www", matches[1])); | |
if (matches2 = /<script\s[^>]*src=['"]cordova.js['"].*\/script>/.exec(content)) | |
{ | |
sys.puts(' Looks like you are including the cordova libs:'); | |
sys.puts(' ' + matches2[0]); | |
sys.puts(''); | |
} | |
else | |
{ | |
sys.puts(' Cannot find the Cordova lib script tag :('); | |
sys.puts(' (If you verify it is included, check my RegExp, it might need to be adjusted)'); | |
sys.puts(''); | |
process.exit(1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
where to put this code ..?