1 exports.config = function(config){
3 // This module provides bootstrap configuration for running dojo in node.js
5 // any command line arguments with the load flag are pushed into deps
6 for(var deps = [], args = [], i = 0; i < process.argv.length; i++){
7 var arg = (process.argv[i] + "").split("=");
15 var fs = require("fs");
17 // make sure global require exists
18 //if (typeof global.require=="undefined"){
19 // global.require= {};
22 // reset the has cache with node-appropriate values;
32 "dojo-dom-ready-api":0,
33 "dojo-publish-privates":1,
39 for(var p in hasCache){
40 config.hasCache[p] = hasCache[p];
43 var vm = require('vm'),
44 path = require('path');
46 // reset some configuration switches with node-appropriate values
48 baseUrl: path.dirname(process.argv[1]),
53 // TODO: really get the locale
58 // define debug for console messages during dev instead of console.log
59 // (node's heavy async makes console.log confusing sometimes)
60 var util = require("util");
61 util.debug(util.inspect(item));
64 eval: function(__text, __urlHint){
65 return vm.runInThisContext(__text, __urlHint);
68 injectUrl: function(url, callback){
70 vm.runInThisContext(fs.readFileSync(url, "utf8"), url);
73 this.log("failed to load resource (" + url + ")");
78 getText: function(url, sync, onLoad){
79 // TODO: implement async and http/https handling
80 onLoad(fs.readFileSync(url, "utf8"));
85 config[p] = nodeConfig[p];