forked from svrjs/svrjs
Replace __dirname with process.dirname (declared as __dirname in index.js)
This commit is contained in:
parent
24b161b0ed
commit
11e7247869
4 changed files with 20 additions and 18 deletions
10
src/index.js
10
src/index.js
|
@ -15,10 +15,12 @@ try {
|
||||||
// Don't use inspector
|
// Don't use inspector
|
||||||
}
|
}
|
||||||
|
|
||||||
|
process.dirname = __dirname;
|
||||||
|
|
||||||
// Create log, mods and temp directories, if they don't exist.
|
// Create log, mods and temp directories, if they don't exist.
|
||||||
if (!fs.existsSync(__dirname + "/log")) fs.mkdirSync(__dirname + "/log");
|
if (!fs.existsSync(process.dirname + "/log")) fs.mkdirSync(process.dirname + "/log");
|
||||||
if (!fs.existsSync(__dirname + "/mods")) fs.mkdirSync(__dirname + "/mods");
|
if (!fs.existsSync(process.dirname + "/mods")) fs.mkdirSync(process.dirname + "/mods");
|
||||||
if (!fs.existsSync(__dirname + "/temp")) fs.mkdirSync(__dirname + "/temp");
|
if (!fs.existsSync(process.dirname + "/temp")) fs.mkdirSync(process.dirname + "/temp");
|
||||||
|
|
||||||
// TODO: process.singleThreaded flag
|
// TODO: process.singleThreaded flag
|
||||||
process.singleThreaded = true;
|
process.singleThreaded = true;
|
||||||
|
@ -102,7 +104,7 @@ if (!process.stdout.isTTY && !inspectorURL) {
|
||||||
|
|
||||||
var wwwrootError = null;
|
var wwwrootError = null;
|
||||||
try {
|
try {
|
||||||
if (cluster.isPrimary || cluster.isPrimary === undefined) process.chdir(process.serverConfig.wwwroot != undefined ? process.serverConfig.wwwroot : __dirname);
|
if (cluster.isPrimary || cluster.isPrimary === undefined) process.chdir(process.serverConfig.wwwroot != undefined ? process.serverConfig.wwwroot : process.dirname);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
wwwrootError = err;
|
wwwrootError = err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ function getInitializePath(to) {
|
||||||
}
|
}
|
||||||
const absoluteTo = path.isAbsolute(to)
|
const absoluteTo = path.isAbsolute(to)
|
||||||
? to
|
? to
|
||||||
: __dirname + (os.platform() == "win32" ? "\\" : "/") + to;
|
: process.dirname + (os.platform() == "win32" ? "\\" : "/") + to;
|
||||||
if (os.platform() == "win32" && cwd[0] != absoluteTo[0]) return "";
|
if (os.platform() == "win32" && cwd[0] != absoluteTo[0]) return "";
|
||||||
const relative = path.relative(cwd, absoluteTo);
|
const relative = path.relative(cwd, absoluteTo);
|
||||||
if (os.platform() == "win32") {
|
if (os.platform() == "win32") {
|
||||||
|
@ -95,9 +95,9 @@ if (process.serverConfig.secure) {
|
||||||
}
|
}
|
||||||
forbiddenPaths.svrjs = getInitializePath(
|
forbiddenPaths.svrjs = getInitializePath(
|
||||||
"./" +
|
"./" +
|
||||||
(__dirname[__dirname.length - 1] != "/"
|
(process.dirname[process.dirname.length - 1] != "/"
|
||||||
? __filename.replace(__dirname + "/", "")
|
? __filename.replace(process.dirname + "/", "")
|
||||||
: __filename.replace(__dirname, "")),
|
: __filename.replace(process.dirname, "")),
|
||||||
);
|
);
|
||||||
forbiddenPaths.serverSideScripts = [];
|
forbiddenPaths.serverSideScripts = [];
|
||||||
if (process.serverConfig.useWebRootServerSideScript) {
|
if (process.serverConfig.useWebRootServerSideScript) {
|
||||||
|
|
|
@ -52,10 +52,10 @@ if (!process.singleThreaded) {
|
||||||
os.platform() === "win32"
|
os.platform() === "win32"
|
||||||
? path.join(
|
? path.join(
|
||||||
"\\\\?\\pipe",
|
"\\\\?\\pipe",
|
||||||
__dirname,
|
process.dirname,
|
||||||
"temp/.W" + process.pid + ".ipc",
|
"temp/.W" + process.pid + ".ipc",
|
||||||
)
|
)
|
||||||
: __dirname + "/temp/.W" + process.pid + ".ipc",
|
: process.dirname + "/temp/.W" + process.pid + ".ipc",
|
||||||
);
|
);
|
||||||
|
|
||||||
process.send = function (message) {
|
process.send = function (message) {
|
||||||
|
@ -64,10 +64,10 @@ if (!process.singleThreaded) {
|
||||||
os.platform() === "win32"
|
os.platform() === "win32"
|
||||||
? path.join(
|
? path.join(
|
||||||
"\\\\?\\pipe",
|
"\\\\?\\pipe",
|
||||||
__dirname,
|
process.dirname,
|
||||||
"temp/.P" + process.pid + ".ipc",
|
"temp/.P" + process.pid + ".ipc",
|
||||||
)
|
)
|
||||||
: __dirname + "/temp/.P" + process.pid + ".ipc",
|
: process.dirname + "/temp/.P" + process.pid + ".ipc",
|
||||||
function () {
|
function () {
|
||||||
fakeIPCConnection.end(message);
|
fakeIPCConnection.end(message);
|
||||||
},
|
},
|
||||||
|
@ -159,10 +159,10 @@ if (!process.singleThreaded) {
|
||||||
os.platform() === "win32"
|
os.platform() === "win32"
|
||||||
? path.join(
|
? path.join(
|
||||||
"\\\\?\\pipe",
|
"\\\\?\\pipe",
|
||||||
__dirname,
|
process.dirname,
|
||||||
"temp/.P" + newWorker.process.pid + ".ipc",
|
"temp/.P" + newWorker.process.pid + ".ipc",
|
||||||
)
|
)
|
||||||
: __dirname + "/temp/.P" + newWorker.process.pid + ".ipc",
|
: process.dirname + "/temp/.P" + newWorker.process.pid + ".ipc",
|
||||||
);
|
);
|
||||||
|
|
||||||
// Cleanup when worker process exits
|
// Cleanup when worker process exits
|
||||||
|
@ -186,10 +186,10 @@ if (!process.singleThreaded) {
|
||||||
os.platform() === "win32"
|
os.platform() === "win32"
|
||||||
? path.join(
|
? path.join(
|
||||||
"\\\\?\\pipe",
|
"\\\\?\\pipe",
|
||||||
__dirname,
|
process.dirname,
|
||||||
"temp/.W" + newWorker.process.pid + ".ipc",
|
"temp/.W" + newWorker.process.pid + ".ipc",
|
||||||
)
|
)
|
||||||
: __dirname + "/temp/.W" + newWorker.process.pid + ".ipc",
|
: process.dirname + "/temp/.W" + newWorker.process.pid + ".ipc",
|
||||||
function () {
|
function () {
|
||||||
fakeWorkerIPCConnection.end(message);
|
fakeWorkerIPCConnection.end(message);
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,7 +13,7 @@ function LOG(s) {
|
||||||
if (enableLoggingIntoFile) {
|
if (enableLoggingIntoFile) {
|
||||||
if (logSync) {
|
if (logSync) {
|
||||||
fs.appendFileSync(
|
fs.appendFileSync(
|
||||||
__dirname +
|
process.dirname +
|
||||||
"/log/" +
|
"/log/" +
|
||||||
(cluster.isPrimary
|
(cluster.isPrimary
|
||||||
? "master"
|
? "master"
|
||||||
|
@ -28,7 +28,7 @@ function LOG(s) {
|
||||||
} else {
|
} else {
|
||||||
if (!logFile) {
|
if (!logFile) {
|
||||||
logFile = fs.createWriteStream(
|
logFile = fs.createWriteStream(
|
||||||
__dirname +
|
process.dirname +
|
||||||
"/log/" +
|
"/log/" +
|
||||||
(cluster.isPrimary
|
(cluster.isPrimary
|
||||||
? "master"
|
? "master"
|
||||||
|
|
Reference in a new issue