forked from mikehostetler/amplify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added script to test all versions of jquery
- Loading branch information
1 parent
3bdab27
commit e1714ee
Showing
3 changed files
with
172 additions
and
118 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
'use strict'; | ||
var path = require('path' ), | ||
fs = require('fs' ), | ||
exec = require('child_process' ).exec, | ||
EOL = require('os' ).EOL, | ||
async = require('async' ); | ||
|
||
var PORT = process.argv[2] || 1982, //1982 is strata default | ||
EXEC_DELAY = process.argv[3] || 10000; //10 seconds between exection by default; gives tests time to run | ||
|
||
var EXTERNAL_DIR = path.join(__dirname, 'external' ), | ||
JQUERY_REGEX = /^jquery-([\d]+\.[\d](?:\.[\d]+)?)\.js$/, | ||
TEST_URL = 'http://localhost:' + PORT + '/test/index.html?jquery='; | ||
|
||
function isNotWhitespace(str) { | ||
return str.trim().length > 0; | ||
} | ||
|
||
if (!fs.existsSync(EXTERNAL_DIR)) { | ||
console.error('cannot locate jquery files'); | ||
process.exit(1); | ||
} | ||
|
||
fs.readdir(EXTERNAL_DIR, function (err, files) { | ||
if (err) { | ||
return console.error(err); | ||
} | ||
files = files.filter(function (file) { | ||
return JQUERY_REGEX.test(file); | ||
}); | ||
var handlers = files.map(function (file) { | ||
var jqueryVersion = JQUERY_REGEX.exec(file)[1]; | ||
JQUERY_REGEX.lastIndex = 0; | ||
var testURL = TEST_URL + jqueryVersion; | ||
|
||
return function (cb) { | ||
console.log('opening ' + testURL); | ||
exec('open ' + testURL, function (err, stdout, stderr) { | ||
setTimeout(function () { | ||
if (err) { | ||
return cb(err.code + ': ' + stderr.toString()); | ||
} | ||
cb(null, stdout.toString()); | ||
}, EXEC_DELAY); | ||
}); | ||
}; | ||
}); | ||
async.series(handlers, function (err, results) { | ||
if (err) { | ||
return console.error(err); | ||
} | ||
console.log(results.filter(isNotWhitespace ).join(EOL)); | ||
}); | ||
}); |