Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#!/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(' Cannot find the Cordova lib script tag :(');
sys.puts(' (If you verify it is included, check my RegExp, it might need to be adjusted)');

This comment has been minimized.

Copy link

commented May 25, 2016

where to put this code ..?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.