webapi-eca/examples/runscript.js

40 lines
826 B
JavaScript
Raw Normal View History

// Generated by CoffeeScript 1.7.1
(function() {
var cs, data, fs, issueApiCall, params, sandbox, src, vm;
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');
issueApiCall = function(method, url, data, options, cb) {
return cb(new Error('not possible'));
};
params = {};
data = fs.readFileSync(process.argv[2], 'utf8');
src = cs.compile(data);
sandbox = {
id: 'test.vm',
params: params,
needlereq: issueApiCall,
log: console.log,
debug: console.log,
exports: {}
};
vm.runInNewContext(src, sandbox, sandbox.id);
console.log('If no error happened until here it seems the script compiled and ran correctly! Congrats!');
}).call(this);