2014-04-06 00:22:39 +00:00
|
|
|
// Generated by CoffeeScript 1.7.1
|
2014-04-06 19:36:34 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
runscript.js
|
|
|
|
|
------------
|
|
|
|
|
|
|
|
|
|
A script that helps to track errors happening durin coffee
|
|
|
|
|
compilation and running of module code
|
|
|
|
|
*/
|
|
|
|
|
|
2014-04-06 00:22:39 +00:00
|
|
|
(function() {
|
2014-04-16 15:42:56 +00:00
|
|
|
var code, crypto, cs, fs, importio, needle, params, request, sandbox, src, vm;
|
2014-04-06 00:22:39 +00:00
|
|
|
|
|
|
|
|
if (!process.argv[2]) {
|
|
|
|
|
console.log('Please provide a path to a coffee file');
|
|
|
|
|
process.exit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fs = require('fs');
|
|
|
|
|
|
|
|
|
|
vm = require('vm');
|
|
|
|
|
|
|
|
|
|
cs = require('coffee-script');
|
|
|
|
|
|
2014-04-06 19:36:34 +00:00
|
|
|
needle = require('needle');
|
|
|
|
|
|
|
|
|
|
crypto = require('crypto-js');
|
|
|
|
|
|
|
|
|
|
request = require('request');
|
|
|
|
|
|
2014-04-16 15:42:56 +00:00
|
|
|
importio = require('import-io').client;
|
2014-04-06 00:22:39 +00:00
|
|
|
|
2014-04-06 19:36:34 +00:00
|
|
|
params = JSON.parse(fs.readFileSync('params.json', 'utf8'));
|
2014-04-06 00:22:39 +00:00
|
|
|
|
2014-04-06 19:36:34 +00:00
|
|
|
code = fs.readFileSync(process.argv[2], 'utf8');
|
2014-04-06 00:22:39 +00:00
|
|
|
|
2014-04-06 19:36:34 +00:00
|
|
|
src = cs.compile(code);
|
2014-04-06 00:22:39 +00:00
|
|
|
|
|
|
|
|
sandbox = {
|
|
|
|
|
id: 'test.vm',
|
2014-04-20 23:34:49 +00:00
|
|
|
params: params,
|
2014-04-16 15:42:56 +00:00
|
|
|
needle: needle,
|
|
|
|
|
request: request,
|
2014-04-06 19:36:34 +00:00
|
|
|
cryptoJS: crypto,
|
2014-04-16 15:42:56 +00:00
|
|
|
importio: importio,
|
2014-04-06 00:22:39 +00:00
|
|
|
log: console.log,
|
|
|
|
|
debug: console.log,
|
2014-04-25 00:24:01 +00:00
|
|
|
setTimeout: setTimeout,
|
|
|
|
|
exports: {},
|
|
|
|
|
pushEvent: function(obj) {
|
|
|
|
|
return console.log(obj);
|
|
|
|
|
}
|
2014-04-20 23:34:49 +00:00
|
|
|
};
|
|
|
|
|
|
2014-04-06 00:22:39 +00:00
|
|
|
vm.runInNewContext(src, sandbox, sandbox.id);
|
|
|
|
|
|
2014-04-25 00:24:01 +00:00
|
|
|
sandbox.exports[process.argv[3]].apply(null, [
|
|
|
|
|
{
|
|
|
|
|
useraccount: "10595",
|
|
|
|
|
semester: "FS14",
|
|
|
|
|
studies: "BSC4",
|
|
|
|
|
major: "BL"
|
|
|
|
|
}
|
|
|
|
|
]);
|
2014-04-06 19:36:34 +00:00
|
|
|
|
|
|
|
|
console.log("If no error happened until here it seems the script compiled and ran correctly! Congrats!");
|
2014-04-06 00:22:39 +00:00
|
|
|
|
|
|
|
|
}).call(this);
|