1/* Copyright IBM Corp. 2016 All Rights Reserved. */ 2exports.config = function(config){ 3 // summary: 4 // This module provides bootstrap configuration for running dojo in node.js 5 6 // any command line arguments with the load flag are pushed into deps 7 for(var deps = [], args = [], i = 0; i < process.argv.length; i++){ 8 var arg = (process.argv[i] + "").split("="); 9 if(arg[0] == "load"){ 10 deps.push(arg[1]); 11 }else{ 12 args.push(arg); 13 } 14 } 15 16 var fs = require("fs"); 17 18 // make sure global require exists 19 //if (typeof global.require=="undefined"){ 20 // global.require= {}; 21 //} 22 23 // reset the has cache with node-appropriate values; 24 var hasCache = { 25 "host-node":1, 26 "host-browser":0, 27 "dom":0, 28 "dojo-has-api":1, 29 "dojo-xhr-factory":0, 30 "dojo-inject-api":1, 31 "dojo-timeout-api":0, 32 "dojo-trace-api":1, 33 "dojo-dom-ready-api":0, 34 "dojo-publish-privates":1, 35 "dojo-sniff":0, 36 "dojo-loader":1, 37 "dojo-test-xd":0, 38 "dojo-test-sniff":0 39 }; 40 for(var p in hasCache){ 41 config.hasCache[p] = hasCache[p]; 42 } 43 44 var vm = require('vm'), 45 path = require('path'); 46 47 // reset some configuration switches with node-appropriate values 48 var nodeConfig = { 49 baseUrl: path.dirname(process.argv[1]), 50 commandLineArgs:args, 51 deps:deps, 52 timeout:0, 53 54 // TODO: really get the locale 55 locale:"en-us", 56 57 loaderPatch: { 58 log:function(item){ 59 // define debug for console messages during dev instead of console.log 60 // (node's heavy async makes console.log confusing sometimes) 61 var util = require("util"); 62 util.debug(util.inspect(item)); 63 }, 64 65 eval: function(__text, __urlHint){ 66 return vm.runInThisContext(__text, __urlHint); 67 }, 68 69 injectUrl: function(url, callback){ 70 try{ 71 vm.runInThisContext(fs.readFileSync(url, "utf8"), url); 72 callback(); 73 }catch(e){ 74 this.log("failed to load resource (" + url + ")"); 75 this.log(e); 76 } 77 }, 78 79 getText: function(url, sync, onLoad){ 80 // TODO: implement async and http/https handling 81 onLoad(fs.readFileSync(url, "utf8")); 82 } 83 } 84 }; 85 for(p in nodeConfig){ 86 config[p] = nodeConfig[p]; 87 } 88};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.