thinkjs/lib/think.js
2014-01-13 11:38:47 +08:00

38 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var path = require("path");
//APP根目錄
if (!global.APP_PATH) {
global.APP_PATH = path.dirname(__dirname) + "/App";
}else{
global.APP_PATH = path.normalize(APP_PATH);
}
//RUNTIME目錄
if (!global.RUNTIME_PATH) {
global.RUNTIME_PATH = global.APP_PATH + '/Runtime';
}else{
global.RUNTIME_PATH = path.normalize(RUNTIME_PATH);
}
//DEBUG模式
if (global.APP_DEBUG === undefined) {
global.APP_DEBUG = false;
};
//静态资源文件的根目录
if (global.RESOURCE_PATH === undefined) {
global.RESOURCE_PATH = "";
};
//执行模式默认为WEB起服务模式
if (global.APP_MODE === undefined) {
global.APP_MODE = "";
};
//可以传一个querystring数据如: xxx=yyy&aaa=bbb
if (process.argv[2]) {
APP_MODE = 'cli';
//模式下的数据
global.APP_MODE_DATA = process.argv[2];
};
//THINKJS的根目录
global.THINK_PATH = __dirname;
//从package.json文件里获取版本号
var version = JSON.parse(require("fs").readFileSync(THINK_PATH + "/../package.json", "utf8")).version;
global.THINK_VERSION = version;
//加载运行时文件
require(THINK_PATH + "/Common/runtime.js");