mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-13 21:21:03 +00:00
Update app.js
This commit is contained in:
parent
01be6b6252
commit
453e63da2e
42
app.js
42
app.js
|
@ -212,23 +212,29 @@ function __include__(FN) {
|
||||||
/**
|
/**
|
||||||
* @FN {string} The name of the file.
|
* @FN {string} The name of the file.
|
||||||
*/
|
*/
|
||||||
function require(FN) {
|
function require(pathname) {
|
||||||
var cache = require.__cache__ = require.__cache__ || {};
|
var cache = require.__cache__ = require.__cache__ || {};
|
||||||
var suffix = (function(pos) {
|
var suffix = (function(pos, s) {
|
||||||
return pos < 0 ? '.' : FN.substr(pos);
|
return pos < 0 ? '.' : s.substr(pos);
|
||||||
})(FN.lastIndexOf('.'));
|
})(pathname.lastIndexOf('.'), pathname);
|
||||||
|
var FN = pathname;
|
||||||
|
|
||||||
if ('.js$.jse$.coffee$.ls$.ts$.re$.res$.enc$'.indexOf(suffix + '$') < 0) FN += ".js";
|
if ('.js$.jse$.coffee$.ls$.ts$.re$.res$.enc$'.indexOf(suffix + '$') < 0) FN += ".js";
|
||||||
if (cache[FN]) return cache[FN];
|
if (cache[FN]) return cache[FN];
|
||||||
|
|
||||||
// get file and directory name
|
// get file and directory name
|
||||||
var __filename__ = (function(getCurrentScriptDirectory, fileExists, path) {
|
var __filename__ = (function(fileExists, path) {
|
||||||
var basepath = getCurrentScriptDirectory();
|
|
||||||
var filepaths = [
|
var filepaths = [
|
||||||
path.join(basepath, FN), // WelsonJS base library
|
FN, // default
|
||||||
path.join(basepath, "Scripts", FN), // NuGet
|
path.join(pathname, "index.js"), // default
|
||||||
path.join(basepath, "bower_components", FN), // Bower
|
path.join(FN + '.enc'), // default (encrypted)
|
||||||
path.join(basepath, "node_modules", FN), // NPM
|
path.join(pathname, 'index.js.enc'), // default (encrypted)
|
||||||
|
path.join("Scripts", FN), // NuGet
|
||||||
|
path.join("Scripts", pathname, "index.js"), // NuGet
|
||||||
|
path.join("bower_components", FN), // Bower
|
||||||
|
path.join("bower_components", pathname, "index.js"), // Bower
|
||||||
|
path.join("node_modules", FN), // NPM
|
||||||
|
path.join("node_modules", pathname, "index.js"), // NPM
|
||||||
];
|
];
|
||||||
var filename = filepaths[0];
|
var filename = filepaths[0];
|
||||||
|
|
||||||
|
@ -242,7 +248,7 @@ function require(FN) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return filename;
|
return filename;
|
||||||
})(require.__getCurrentScriptDirectory__, function(filename) {
|
})(function(filename) {
|
||||||
return CreateObject("Scripting.FileSystemObject").FileExists(filename);
|
return CreateObject("Scripting.FileSystemObject").FileExists(filename);
|
||||||
}, {
|
}, {
|
||||||
join: function() {
|
join: function() {
|
||||||
|
@ -253,8 +259,16 @@ function require(FN) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var __dirname__ = require.__getDirName__(__filename__);
|
var __dirname__ = (function(dirname) {
|
||||||
var T = require.__load__(FN);
|
var currentScriptDirectory = require.__getCurrentScriptDirectory__();
|
||||||
|
return dirname.length > 0 ? currentScriptDirectory + "\\" + dirname : currentScriptDirectory;
|
||||||
|
})(require.__getDirName__(__filename__));
|
||||||
|
var T = require.__load__(__filename__);
|
||||||
|
|
||||||
|
// check the suffix again
|
||||||
|
suffix = (function(pos, s) {
|
||||||
|
return pos < 0 ? '.' : s.substr(pos);
|
||||||
|
})(__filename__.lastIndexOf('.'), __filename__);
|
||||||
|
|
||||||
// transpile
|
// transpile
|
||||||
switch (suffix) {
|
switch (suffix) {
|
||||||
|
@ -292,7 +306,7 @@ function require(FN) {
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ".enc": // Encrypted
|
case ".enc": // HIGHT(ISO/IEC 18033-3) encrypted
|
||||||
T = (function(encryptedData) {
|
T = (function(encryptedData) {
|
||||||
try {
|
try {
|
||||||
var toolkit = CreateObject("WelsonJS.Toolkit");
|
var toolkit = CreateObject("WelsonJS.Toolkit");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user