Simplified the NODE tests

This commit is contained in:
Jeff Parsons 2015-09-16 15:32:49 -07:00
commit 646acf3a8d
53 changed files with 106 additions and 89 deletions

View file

@ -53,7 +53,7 @@
/* global window: true, DEBUG: true */
if (typeof module !== 'undefined') {
if (NODE) {
require("./defines");
var usr = require("./usrlib");
var web = require("./weblib");
@ -997,4 +997,4 @@ Component.prototype = {
}
};
if (typeof module !== 'undefined') module.exports = Component;
if (NODE) module.exports = Component;

View file

@ -64,7 +64,15 @@ var DEBUG = true; // this @define is overridden by the Closure Com
*/
var MAXDEBUG = false; // this @define is overridden by the Closure Compiler (to false) to remove MAXDEBUG-only code
/*
* NODE should be true if we're running under NodeJS (eg, command-line), false if not (eg, web browser)
*/
var NODE = false;
if (typeof module !== 'undefined') {
NODE = true;
}
if (NODE) {
global.window = false; // provides an alternative "if (typeof window === 'undefined')" (ie, "if (window) ...")
global.APPNAME = APPNAME;
global.APPVERSION = APPVERSION;
@ -72,6 +80,7 @@ if (typeof module !== 'undefined') {
global.COMPILED = COMPILED;
global.DEBUG = DEBUG;
global.MAXDEBUG = MAXDEBUG;
global.NODE = NODE;
/*
* TODO: When we're "required" by Node, should we return anything via module.exports?
*/

View file

@ -215,4 +215,4 @@ DiskAPI.ATTR = {
ARCHIVE: 0x20 // PC-DOS 2.0 and up
};
if (typeof module !== 'undefined') module.exports = DiskAPI;
if (NODE) module.exports = DiskAPI;

View file

@ -82,4 +82,4 @@ var DumpAPI = {
DumpAPI.asDiskCommands = [DumpAPI.QUERY.DIR, DumpAPI.QUERY.DISK, DumpAPI.QUERY.PATH];
DumpAPI.asFileCommands = [DumpAPI.QUERY.FILE];
if (typeof module !== 'undefined') module.exports = DumpAPI;
if (NODE) module.exports = DumpAPI;

View file

@ -34,7 +34,7 @@
/* global window: true, XSLTProcessor: false, APPNAME: false, APPVERSION: false, DEBUG: true */
if (typeof module !== 'undefined') {
if (NODE) {
var Component;
var str = require("./strlib");
var web = require("./weblib");

View file

@ -36,7 +36,7 @@
var net = {};
if (typeof module !== 'undefined') {
if (NODE) {
var sServerRoot;
var fs = require("fs");
var http = require("http");
@ -396,4 +396,4 @@ net.loadResource = function(sURL, fAsync, data, componentNotify, fnNotify, pNoti
return [nErrorCode, sResponse];
};
if (typeof module !== 'undefined') module.exports = net;
if (NODE) module.exports = net;

View file

@ -87,4 +87,4 @@ proc.getArgs = function() {
return {argc: argc, argv: argv};
};
if (typeof module !== 'undefined') module.exports = proc;
if (NODE) module.exports = proc;

View file

@ -50,4 +50,4 @@ var ReportAPI = {
}
};
if (typeof module !== 'undefined') module.exports = ReportAPI;
if (NODE) module.exports = ReportAPI;

View file

@ -402,4 +402,4 @@ str.trim = function(s)
return s.replace(/^\s+|\s+$/g, "");
};
if (typeof module !== 'undefined') module.exports = str;
if (NODE) module.exports = str;

View file

@ -70,4 +70,4 @@ var UserAPI = {
}
};
if (typeof module !== 'undefined') module.exports = UserAPI;
if (NODE) module.exports = UserAPI;

View file

@ -316,4 +316,4 @@ usr.indexOf = function(a, t, i)
return -1;
};
if (typeof module !== 'undefined') module.exports = usr;
if (NODE) module.exports = usr;

View file

@ -118,7 +118,7 @@
/* global window: true, setTimeout: false, clearTimeout: false, SITEHOST: false */
if (typeof module !== 'undefined') {
if (NODE) {
var Component;
require("./defines");
var str = require("./strlib");
@ -147,7 +147,7 @@ var web = {};
*/
web.log = function(s, type)
{
if (typeof module !== 'undefined') {
if (NODE) {
if (!Component) Component = require("./component");
}
Component.log(s, type);
@ -164,7 +164,7 @@ web.log = function(s, type)
*/
web.notice = function(s, fPrintOnly, id)
{
if (typeof module !== 'undefined') {
if (NODE) {
if (!Component) Component = require("./component");
}
Component.notice(s, fPrintOnly, id);
@ -191,7 +191,7 @@ web.notice = function(s, fPrintOnly, id)
web.loadResource = function(sURL, fAsync, data, componentNotify, fnNotify, pNotify)
{
fAsync = !!fAsync; // ensure that fAsync is a valid boolean (Internet Explorer xmlHTTP functions insist on it)
if (typeof module !== 'undefined') {
if (NODE) {
/*
* We don't even need to load Component, because we can't use any of the code below
* within Node anyway. Instead, we must hand this request off to our network library.
@ -816,4 +816,4 @@ web.onPageEvent('onload', function onPageLoad() { web.fPageReady = true; web.doP
web.onPageEvent('onpageshow', function onPageShow() { web.doPageEvent(web.aPageEventHandlers['show']); });
web.onPageEvent(web.isUserAgent("Opera") || web.isUserAgent("iOS")? 'onunload' : 'onbeforeunload', function onPageUnload() { web.doPageEvent(web.aPageEventHandlers['exit']); });
if (typeof module !== 'undefined') module.exports = web;
if (NODE) module.exports = web;