Intoduce UseObject(<string>, <function>) in app.js

Intoduce UseObject(<string>, <function>) in app.js
This commit is contained in:
Namhyeon Go 2025-08-05 17:28:38 +09:00 committed by GitHub
parent fe74f360d9
commit 1398c1b359
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

15
app.js
View File

@ -187,6 +187,17 @@ if (typeof CreateObject === "undefined") {
};
}
if (typeof UseObject === "undefined") {
var UseObject = function(progId, callback) {
var obj = CreateObject(progId);
try {
return callback(obj);
} finally {
obj = null;
}
}
}
/**
* @FN {string} The name of the file.
*/
@ -283,7 +294,9 @@ function require(pathname) {
return filename;
})({
existsSync: function(filename) {
return CreateObject("Scripting.FileSystemObject").FileExists(filename);
return UseObject("Scripting.FileSystemObject", function(fso) {
return fso.FileExists(filename);
});
}
}, {
join: function() {