This commit is contained in:
Namhyeon Go 2020-07-21 18:01:38 +09:00
parent 321a83fa72
commit ef04c7ce0c
3 changed files with 20 additions and 5 deletions

13
app.js
View File

@ -74,11 +74,22 @@ function require(FN) {
if (FN.substr(FN.length - 3) !== '.js') FN += ".js";
if (cache[FN]) return cache[FN];
// get current script directory
var getCurrentScriptDirectory = function() {
if(typeof(WScript) !== "undefined") {
var path = WScript.ScriptFullName;
var pos = path.lastIndexOf("\\");
return path.substring(0, pos);
} else {
return ".";
}
};
// load script file
var FSO = CreateObject("Scripting.FileSystemObject");
var T = null;
try {
var TS = FSO.OpenTextFile(FN, 1);
TS = FSO.OpenTextFile(getCurrentScriptDirectory() + "\\" + FN, 1);
if (TS.AtEndOfStream) return "";
T = TS.ReadAll();
TS.Close();

View File

@ -2,7 +2,7 @@
// Shell API
////////////////////////////////////////////////////////////////////////
var FILE = require('lib/file');
var FILE = require("lib/file");
exports.VERSIONINFO = "Shell Module (shell.js) version 0.1";
exports.global = global;

View File

@ -101,9 +101,13 @@ exports.getCurrentWorkingDirectory = function() {
// "console only";
exports.getCurrentScriptDirectory = function() {
var path = WScript.ScriptFullName;
var pos = path.lastIndexOf("\\");
return path.substring(0, pos);
if(typeof(WScript) !== "undefined") {
var path = WScript.ScriptFullName;
var pos = path.lastIndexOf("\\");
return path.substring(0, pos);
} else {
return ".";
}
};
exports.getNetworkInterfaces = function() {