From fe74f360d9b69590baf3d1249f8b3fe585bb0a93 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Tue, 5 Aug 2025 16:39:44 +0900 Subject: [PATCH 1/8] Introduce Array.form() polyfills Introduce Array.form() polyfills --- lib/std.js | 93 +++++++++++++++++++++++++++++------------------------- 1 file changed, 50 insertions(+), 43 deletions(-) diff --git a/lib/std.js b/lib/std.js index 8ff4a09..69c7b93 100644 --- a/lib/std.js +++ b/lib/std.js @@ -3,9 +3,8 @@ // SPDX-License-Identifier: GPL-3.0-or-later // https://github.com/gnh1201/welsonjs // -// WelsonJS Standard Library +// WelsonJS Standard Library (Polyfills and shared functions) // -// Polyfills if (!Function.prototype.GetResource) { Function.prototype.GetResource = function(ResourceName) { if (!this.Resources) { @@ -23,50 +22,58 @@ if (!Function.prototype.GetResource) { } } -// The provided code snippet has been corrected by ChatGPT. -// https://chat.openai.com/share/eaab056c-d265-4ee3-b355-9f29176a9caa -// Related issues: #75 #42 #30 -if (typeof Enumerator !== "undefined") { - Enumerator.prototype.toArray = function() { - var result = []; - while (!this.atEnd()) { - var currentItem = this.item(); - var currentItemProperties = currentItem.Properties_; - var itemObject = {}; - - var propertiesEnumerator = new Enumerator(currentItemProperties); - while (!propertiesEnumerator.atEnd()) { - var property = propertiesEnumerator.item(); - if (typeof property.value !== "unknown") { // The type "Unknown" is Array - itemObject[property.name] = property.value; - } else { - var arrayValues = []; - var index = 0; - while (true) { - try { - arrayValues.push(property.value(index)); - index++; - } catch (e) { - break; - } - } - itemObject[property.name] = arrayValues; - } - propertiesEnumerator.moveNext(); - } - result.push(itemObject); - this.moveNext(); - } - - return result; - }; -} - -// Global APIs function GetResource(ResourceName) { return arguments.callee.caller.GetResource(ResourceName); } +(function() { + var originalFrom = Array.from; + + function convertToArray(v) { + var result = []; + while (!v.atEnd()) { + var item = v.item(); + result.push(typeof item === "unknown" ? Array.from(item) : item); + v.moveNext(); + } + return result; + } + + function convertToObject(v) { + var obj = {}; + var props = new Enumerator(v.Properties_); + while (!props.atEnd()) { + var prop = props.item(); + obj[prop.name] = typeof prop.value === "unknown" ? + Array.from(prop.value) : + prop.value; + props.moveNext(); + } + return obj; + } + + Array.from = function(value) { + if (value && typeof value.item === "unknown") { + value = new Enumerator(value); + } + + if (value instanceof Enumerator) { + return value && value.Properties_ ? + convertToObject(value) : + convertToArray(value); + } + + return originalFrom ? originalFrom(value) : Array.prototype.slice.call(value); + }; + + Array.from.toString = function() { + return originalFrom.toString(); + }; + + // compatible under version 0.2.7.55 + Enumerator.prototype.toArray = Array.from; +})(); + // [lib/std] the time of `sleep()' function is not accuracy #34 function sleep(ms, callback) { var handler = null; @@ -623,7 +630,7 @@ exports.alert = alert; exports.confirm = confirm; exports.prompt = prompt; -exports.VERSIONINFO = "WelsonJS Standard Library (std.js) version 0.8.18"; +exports.VERSIONINFO = "WelsonJS Standard Library (std.js) version 0.8.19"; exports.AUTHOR = "gnh1201@catswords.re.kr"; exports.global = global; exports.require = global.require; From 1398c1b359af1789967fa3b84885ff1fc6fc55d1 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Tue, 5 Aug 2025 17:28:38 +0900 Subject: [PATCH 2/8] Intoduce UseObject(, ) in app.js Intoduce UseObject(, ) in app.js --- app.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index c28e9d9..38e8b78 100644 --- a/app.js +++ b/app.js @@ -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() { From 3de5b618db48419bae5300ea800b5f8703a7b35a Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Tue, 5 Aug 2025 17:30:20 +0900 Subject: [PATCH 3/8] Introduce getFilesFromFolder() and clean the code Introduce getFilesFromFolder() and clean the code --- lib/file.js | 218 +++++++++++++++++++--------------------------------- 1 file changed, 77 insertions(+), 141 deletions(-) diff --git a/lib/file.js b/lib/file.js index a7aa32b..3541bb3 100644 --- a/lib/file.js +++ b/lib/file.js @@ -8,207 +8,143 @@ var STD = require("lib/std"); var PipeIPC = require("lib/pipe-ipc"); -///////////////////////////////////////////////////////////////////////////////// -// fileExists -///////////////////////////////////////////////////////////////////////////////// - -function fileExists(FN) { - var FSO = CreateObject("Scripting.FileSystemObject"); - var exists = FSO.FileExists(FN); - FSO = null; - return exists; +function fileExists(path) { + return UseObject("Scripting.FileSystemObject", function(fso) { + return fso.FileExists(path); + }); } -///////////////////////////////////////////////////////////////////////////////// -// folderExists -///////////////////////////////////////////////////////////////////////////////// - -function folderExists(FN) { - var FSO = CreateObject("Scripting.FileSystemObject"); - var exists = FSO.FolderExists(FN); - FSO = null; - return exists; +function folderExists(path) { + return UseObject("Scripting.FileSystemObject", function(fso) { + return fso.FolderExists(path); + }); } -///////////////////////////////////////////////////////////////////////////////// -// fileGet -///////////////////////////////////////////////////////////////////////////////// - -function fileGet(FN) { - var FSO = CreateObject("Scripting.FileSystemObject"); - var file = FSO.GetFile(FN); - FSO = null; - return file; +function fileGet(path) { + return UseObject("Scripting.FileSystemObject", function(fso) { + return fso.GetFile(path); + }); } -///////////////////////////////////////////////////////////////////////////////// -// readFile -// Read the conents of the pass filename and return as a string -///////////////////////////////////////////////////////////////////////////////// -function readFile(FN, charset) { +function readFile(path, charset) { if (typeof charset === "undefined") { - console.warn("CHARSET has not been passed. Force to UTF-8."); + console.warn("CHARSET not passed. Defaulting to UTF-8."); charset = PipeIPC.CdoUTF_8; } - var text = ''; var pipe = PipeIPC.connect("volatile"); pipe.setCharset(charset); - pipe.loadFromFile(FN, charset); - text += pipe.read(); + pipe.loadFromFile(path, charset); + var text = pipe.read(); pipe.destroy(); return text; } -///////////////////////////////////////////////////////////////////////////////// -// writeFile -// Write the passed content to named disk file -///////////////////////////////////////////////////////////////////////////////// - -function writeFile(FN, content, charset) { +function writeFile(path, content, charset) { if (typeof content === "undefined") { - console.warn("CONTENT has not been passed. Force to empty string."); + console.warn("CONTENT not passed. Defaulting to empty string."); content = ''; } if (typeof charset === "undefined") { - console.warn("CHARSET has not been passed. Force to UTF-8."); + console.warn("CHARSET not passed. Defaulting to UTF-8."); charset = PipeIPC.CdoUTF_8; } var pipe = PipeIPC.connect("volatile"); pipe.setCharset(charset); - pipe.startRecorder(FN, PipeIPC.ForWriting); + pipe.startRecorder(path, PipeIPC.ForWriting); pipe.write(content); pipe.destroy(); + return true; } -///////////////////////////////////////////////////////////////////////////////// -// writeBinaryFile -///////////////////////////////////////////////////////////////////////////////// - -function writeBinaryFile(FN, DATA) { - var BinaryStream = CreateObject("ADODB.Stream"); - BinaryStream.Type = PipeIPC.adTypeBinary; - BinaryStream.Open(); - BinaryStream.Write(DATA); - BinaryStream.SaveToFile(FN, adSaveCreateOverWrite); - BinaryStream.Close(); +function writeBinaryFile(path, data) { + var binaryStream = CreateObject("ADODB.Stream"); + binaryStream.Type = PipeIPC.adTypeBinary; + binaryStream.Open(); + binaryStream.Write(data); + binaryStream.SaveToFile(path, adSaveCreateOverWrite); + binaryStream.Close(); } -///////////////////////////////////////////////////////////////////////////////// -// moveFile -///////////////////////////////////////////////////////////////////////////////// - -function moveFile(FROM, TO) { - var FSO = CreateObject("Scripting.FileSystemObject"); - var result = FSO.MoveFile(FROM, TO); - FSO = null; - return result; +function moveFile(fromPath, toPath) { + return UseObject("Scripting.FileSystemObject", function(fso) { + return fso.MoveFile(fromPath, toPath); + }); } -///////////////////////////////////////////////////////////////////////////////// -// createFolder -///////////////////////////////////////////////////////////////////////////////// - -function createFolder(FN) { - var FSO = CreateObject("Scripting.FileSystemObject"); - var result = FSO.CreateFolder(FN); - FSO = null; - return result; +function createFolder(path) { + return UseObject("Scripting.FileSystemObject", function(fso) { + return fso.CreateFolder(path); + }); } -///////////////////////////////////////////////////////////////////////////////// -// deleteFolder -///////////////////////////////////////////////////////////////////////////////// - -function deleteFolder(FN) { - var FSO = CreateObject("Scripting.FileSystemObject"); - var result = FSO.DeleteFolder(FN); - FSO = null; - return result; +function deleteFolder(path) { + return UseObject("Scripting.FileSystemObject", function(fso) { + return fso.DeleteFolder(path); + }); } -///////////////////////////////////////////////////////////////////////////////// -// deleteFile -///////////////////////////////////////////////////////////////////////////////// - -function deleteFile(FN) { - var FSO = CreateObject("Scripting.FileSystemObject"); - var result = FSO.DeleteFile(FN); - FSO = null; - return result; +function deleteFile(path) { + return UseObject("Scripting.FileSystemObject", function(fso) { + return fso.DeleteFile(path); + }); } -///////////////////////////////////////////////////////////////////////////////// -// includeFile -///////////////////////////////////////////////////////////////////////////////// - -function includeFile(FN) { +function includeFile(path) { try { - eval(readFile(FN)); + eval(readFile(path)); } catch (e) { - console.error(e.message, "in", FN); + console.error(e.message, "in", path); } } -///////////////////////////////////////////////////////////////////////////////// -// appendFile -///////////////////////////////////////////////////////////////////////////////// +function getFilesFromFolder(path) { + if (!folderExists(path)) return []; -function appendFile(FN, content, charset) { - var result = false; - var pipe = PipeIPC.connect(PipeIPC.CRC32(FN)); + var folder = UseObject("Scripting.FileSystemObject", function(fso) { + return fso.GetFolder(path); + }); + + return Array.from(folder.Files); +} + +function appendFile(path, content, charset) { + var pipe = PipeIPC.connect(PipeIPC.CRC32(path)); pipe.setCharset(charset); - pipe.startRecorder(FN, PipeIPC.ForAppending); - result = pipe.write(content); + pipe.startRecorder(path, PipeIPC.ForAppending); + var result = pipe.write(content); pipe.close(); - return result; } -///////////////////////////////////////////////////////////////////////////////// -// prependFile -///////////////////////////////////////////////////////////////////////////////// - -function prependFile(FN, content, charset) { +function prependFile(path, content, charset) { var pipe = PipeIPC.connect("volatile"); pipe.setCharset(charset); - pipe.startRecorder(FN, PipeIPC.ForWriting); + pipe.startRecorder(path, PipeIPC.ForWriting); pipe.write(content); pipe.destroy(); return true; } -///////////////////////////////////////////////////////////////////////////////// -// rotateFile -///////////////////////////////////////////////////////////////////////////////// - -function rotateFile(FN, content, numOfLines, charset) { - var result = false; - var pipe = PipeIPC.connect(PipeIPC.CRC32(FN)); +function rotateFile(path, content, numOfLines, charset) { + var pipe = PipeIPC.connect(PipeIPC.CRC32(path)); pipe.setCharset(charset); pipe.setMaxSentences(numOfLines); - pipe.startRecorder(FN, PipeIPC.ForAppending); - result = pipe.write(content); + pipe.startRecorder(path, PipeIPC.ForAppending); + var result = pipe.write(content); pipe.close(); - return result; } -// Function to load and parse the .env file -var loadEnvFromFile = function(envFilePath, callback) { +function loadEnvFromFile(path, callback) { try { - // Read the file content using PipeIPC.CdoCharset.CdoUTF_8 encoding - var envString = readFile(envFilePath, PipeIPC.CdoCharset.CdoUTF_8); - - // Parse the environment variables + var envString = readFile(path, PipeIPC.CdoCharset.CdoUTF_8); var envConfig = parseEnv(envString); + console.log('Environment variables loaded from ' + path); - console.log('Environment variables loaded from ' + envFilePath); - - // Call the callback function if provided if (typeof callback === "function") { try { callback(envConfig); @@ -217,23 +153,22 @@ var loadEnvFromFile = function(envFilePath, callback) { } } } catch (e) { - console.error('Error reading environment file:', envFilePath, e.message); + console.error('Error reading environment file:', path, e.message); } -}; +} -// Function to find --env-file argument in the args array and load the environment file -var loadEnvFromArgs = function(args, callback) { +function loadEnvFromArgs(args, callback) { var envFileArg = args.find(function(x) { return x.startsWith('--env-file='); }); if (envFileArg) { - var envFilePath = envFileArg.split('=')[1]; - loadEnvFromFile(envFilePath, callback); + var path = envFileArg.split('=')[1]; + loadEnvFromFile(path, callback); } else { console.warn('No --env-file argument provided.'); } -}; +} exports.fileExists = fileExists; exports.folderExists = folderExists; @@ -246,6 +181,7 @@ exports.createFolder = createFolder; exports.deleteFolder = deleteFolder; exports.deleteFile = deleteFile; exports.includeFile = includeFile; +exports.getFilesFromFolder = getFilesFromFolder; exports.appendFile = appendFile; exports.rotateFile = rotateFile; exports.loadEnvFromFile = loadEnvFromFile; @@ -253,7 +189,7 @@ exports.loadEnvFromArgs = loadEnvFromArgs; exports.CdoCharset = PipeIPC.CdoCharset; -exports.VERSIONINFO = "File IO Library (file.js) version 0.2.13"; +exports.VERSIONINFO = "File IO Library (file.js) version 0.2.14"; exports.AUTHOR = "gnh1201@catswords.re.kr"; exports.global = global; exports.require = global.require; From 6e89bda4532bbb9c36c61f2773e904c81d886ae4 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Tue, 5 Aug 2025 17:31:48 +0900 Subject: [PATCH 4/8] Remove makeInterface() and replace to UseObject() Remove makeInterface() and replace to UseObject() --- lib/pipe-ipc.js | 112 ++++++++++++++++++++++++++---------------------- 1 file changed, 61 insertions(+), 51 deletions(-) diff --git a/lib/pipe-ipc.js b/lib/pipe-ipc.js index 3903314..c3e6fa7 100644 --- a/lib/pipe-ipc.js +++ b/lib/pipe-ipc.js @@ -98,25 +98,31 @@ function makeProbabilityBit(p) { return !( p > 0.0 ? ( (randomize() / p) > 1.0 ) : true) ? 1 : 0; } -function makeInterface(i) { - return CreateObject(["Scripting.FileSystemObject", "ADODB.Stream"][i]); -} - function openTextFile(filename, iomode) { - return makeInterface(0).OpenTextFile(filename, iomode, true, TristateTrue); + return UseObject("Scripting.FileSystemObject", function(fso) { + return fso.OpenTextFile(filename, iomode, true, TristateTrue); + }); } function checkFileExists(filename) { - return makeInterface(0).FileExists(filename);; + return UseObject("Scripting.FileSystemObject", function(fso) { + return fso.FileExists(filename); + }); } function deleteFile(filename) { - if (checkFileExists(filename)) makeInterface(0).DeleteFile(filename); + if (checkFileExists(filename)) { + return UseObject("Scripting.FileSystemObject", function(fso) { + fso.DeleteFile(filename); + }); + } } function getFileSize(filename) { try { - return makeInterface(0).GetFile(filename).Size; + return UseObject("Scripting.FileSystemObject", function(fso) { + return fso.GetFile(filename).Size; + }); } catch (e) { return -1; } @@ -130,40 +136,43 @@ function Converter() { }; this.getBinaryFromText = function() { - var stream = makeInterface(1); - stream.Type = adTypeText; - stream.CharSet = CdoCharset.CdoUTF_8; - stream.Open(); - stream.WriteText(this.value); - stream.Position = 0; - stream.Type = adTypeBinary; - return stream.Read(); + return UseObject("ADODB.Stream", function(stream) { + stream.Type = adTypeText; + stream.CharSet = CdoCharset.CdoUTF_8; + stream.Open(); + stream.WriteText(this.value); + stream.Position = 0; + stream.Type = adTypeBinary; + return stream.Read(); + }); }; this.getTextFromBinary = function() { - var stream = makeInterface(1); - stream.Type = adTypeBinary; - stream.Open(); - stream.Write(this.value); - stream.Position = 0; - stream.Type = adTypeText; - stream.CharSet = CdoCharset.CdoUTF_8; - return stream.ReadText(); + return UseObject("ADODB.Stream", function(stream) { + stream.Type = adTypeBinary; + stream.Open(); + stream.Write(this.value); + stream.Position = 0; + stream.Type = adTypeText; + stream.CharSet = CdoCharset.CdoUTF_8; + return stream.ReadText(); + }); }; this.repositionObject = function(stream, position) { position = (position !== "number" ? 0 : position); + + return UseObject("ADODB.Stream", function(newStream) { + newStream.Type = adTypeBinary; + newStream.Mode = adModeReadWrite; + newStream.Open(); + stream.Position = position; + stream.CopyTo(newStream); + stream.Flush(); + stream.Close(); + return newStream; + }); - var _stream = makeInterface(1); - _stream.Type = adTypeBinary; - _stream.Mode = adModeReadWrite; - _stream.Open(); - stream.Position = position; - stream.CopyTo(_stream); - stream.Flush(); - stream.Close(); - - return _stream; }; } @@ -399,14 +408,15 @@ function PipeIPC() { } // Convert UTF-16 BOM to a character set - var stream = makeInterface(1); - stream.Type = adTypeText; - stream.Charset = charset; - stream.Open(); - stream.WriteText(str); - stream = (new Converter()).repositionObject(stream, 3); - stream.SaveToFile(dst, adSaveCreateOverWrite); - stream.Close(); + UseObject("ADODB.Stream", function(stream) { + stream.Type = adTypeText; + stream.Charset = charset; + stream.Open(); + stream.WriteText(str); + stream = (new Converter()).repositionObject(stream, 3); + stream.SaveToFile(dst, adSaveCreateOverWrite); + stream.Close(); + }); // Set a result isCommited = true; @@ -462,7 +472,7 @@ function PipeIPC() { this.openReader(); text += this._read(this.reader); isReadCompleted = true; - + this.lastReadTime = this.getCurrentTime(); this.closeReader(); } catch (e) { @@ -495,15 +505,15 @@ function PipeIPC() { var isReadCompleted = false; while (!isReadCompleted) { try { - var ado = makeInterface(1); - ado.Charset = charset; - ado.Open(); - ado.LoadFromFile(filename); - text += ado.ReadText(); - ado.Close(); + UseObject("ADODB.Stream", function(stream) { + stream.Charset = charset; + stream.Open(); + stream.LoadFromFile(filename); + text += stream.ReadText(); + stream.Close(); + }); isReadCompleted = true; } catch (e) { - //console.log(e.message); isReadCompleted = false; } } @@ -555,7 +565,7 @@ exports.adSaveCreateNotExist = adSaveCreateNotExist; exports.adSaveCreateOverWrite = adSaveCreateOverWrite; exports.adModeReadWrite = adModeReadWrite; -exports.VERSIONINFO = "PIPE-based IPC Module (pipe-ipc.js) version 0.1.23"; +exports.VERSIONINFO = "PIPE-based IPC Module (pipe-ipc.js) version 0.1.24"; exports.AUTHOR = "gnh1201@catswords.re.kr"; exports.global = global; exports.require = require; From 0ab35aab7c9af70ec9f2dd45bb0a68c2266a75ff Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Tue, 5 Aug 2025 17:33:43 +0900 Subject: [PATCH 5/8] Enable the worksheet activation on the screen Enable the worksheet activation on the screen --- lib/msoffice.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/msoffice.js b/lib/msoffice.js index 32fd718..d33ff33 100644 --- a/lib/msoffice.js +++ b/lib/msoffice.js @@ -72,6 +72,10 @@ function Excel() { } else { this.currentWorksheet = this.currentWorkbook.Worksheets(idx); } + + // switch to the worksheet + this.currentWorksheet.Activate(); + return this; }; @@ -119,7 +123,7 @@ function PowerPoint() { console.info("Microsoft Office PowerPoint", this.version); - this.currentPresentation = null; + this.currentPresentation = null; this.open = function(filename) { if (typeof filename !== "undefined") { @@ -129,16 +133,16 @@ function PowerPoint() { } if (FILE.fileExists(filename)) { console.info("FOUND", filename); - this.application.Presentations.Open(filename); - this.currentPresentation = this.application.ActivePresentation; + this.application.Presentations.Open(filename); + this.currentPresentation = this.application.ActivePresentation; } else { console.warn("NOT FOUND", filename); - this.currentPresentation = this.application.Presentations.Add(true); + this.currentPresentation = this.application.Presentations.Add(true); } } else { this.currentPresentation = this.application.Presentations.Add(true); } - //this.selectPresentation(1); + //this.selectPresentation(1); }; this.selectPresentation = function(idx) { @@ -223,7 +227,7 @@ exports.Excel = Excel; exports.PowerPoint = PowerPoint; exports.Word = Word; -exports.VERSIONINFO = "Microsoft Office interface (msoffice.js) version 0.2.0"; +exports.VERSIONINFO = "Microsoft Office interface (msoffice.js) version 0.2.1"; exports.AUTHOR = "gnh1201@catswords.re.kr"; exports.global = global; exports.require = global.require; From 68a57f15fb27fa22d8d8638dcda25bdbf60f9b2f Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Tue, 5 Aug 2025 17:44:34 +0900 Subject: [PATCH 6/8] Update app.js --- app.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app.js b/app.js index 38e8b78..ceee604 100644 --- a/app.js +++ b/app.js @@ -189,10 +189,17 @@ if (typeof CreateObject === "undefined") { if (typeof UseObject === "undefined") { var UseObject = function(progId, callback) { + var _dispose = function(obj) { + try { + obj.Close(); + } catch (e) { /* ignore */ } + }; + var obj = CreateObject(progId); try { return callback(obj); } finally { + _dispose(obj); obj = null; } } From 444b80e3b59c04cee049b7ca5fca66f43543d2ce Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Tue, 5 Aug 2025 17:45:46 +0900 Subject: [PATCH 7/8] Update file.js --- lib/file.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/file.js b/lib/file.js index 3541bb3..f312531 100644 --- a/lib/file.js +++ b/lib/file.js @@ -61,12 +61,13 @@ function writeFile(path, content, charset) { } function writeBinaryFile(path, data) { - var binaryStream = CreateObject("ADODB.Stream"); - binaryStream.Type = PipeIPC.adTypeBinary; - binaryStream.Open(); - binaryStream.Write(data); - binaryStream.SaveToFile(path, adSaveCreateOverWrite); - binaryStream.Close(); + return UseObject("ADODB.Stream", function(stream) { + stream.Type = PipeIPC.adTypeBinary; + stream.Open(); + stream.Write(data); + stream.SaveToFile(path, adSaveCreateOverWrite); + stream.Close(); + }); } function moveFile(fromPath, toPath) { @@ -189,7 +190,7 @@ exports.loadEnvFromArgs = loadEnvFromArgs; exports.CdoCharset = PipeIPC.CdoCharset; -exports.VERSIONINFO = "File IO Library (file.js) version 0.2.14"; +exports.VERSIONINFO = "File IO Library (file.js) version 0.2.15"; exports.AUTHOR = "gnh1201@catswords.re.kr"; exports.global = global; exports.require = global.require; From 665642586b9f2e1613dfe09288117dada96c280c Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Tue, 5 Aug 2025 17:48:13 +0900 Subject: [PATCH 8/8] Fix indentation on lib/pipe-ipc.js Fix indentation on lib/pipe-ipc.js --- lib/pipe-ipc.js | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/pipe-ipc.js b/lib/pipe-ipc.js index c3e6fa7..693c24a 100644 --- a/lib/pipe-ipc.js +++ b/lib/pipe-ipc.js @@ -105,24 +105,24 @@ function openTextFile(filename, iomode) { } function checkFileExists(filename) { - return UseObject("Scripting.FileSystemObject", function(fso) { - return fso.FileExists(filename); - }); + return UseObject("Scripting.FileSystemObject", function(fso) { + return fso.FileExists(filename); + }); } function deleteFile(filename) { if (checkFileExists(filename)) { - return UseObject("Scripting.FileSystemObject", function(fso) { - fso.DeleteFile(filename); - }); - } + return UseObject("Scripting.FileSystemObject", function(fso) { + fso.DeleteFile(filename); + }); + } } function getFileSize(filename) { try { - return UseObject("Scripting.FileSystemObject", function(fso) { - return fso.GetFile(filename).Size; - }); + return UseObject("Scripting.FileSystemObject", function(fso) { + return fso.GetFile(filename).Size; + }); } catch (e) { return -1; } @@ -408,15 +408,15 @@ function PipeIPC() { } // Convert UTF-16 BOM to a character set - UseObject("ADODB.Stream", function(stream) { - stream.Type = adTypeText; - stream.Charset = charset; - stream.Open(); - stream.WriteText(str); - stream = (new Converter()).repositionObject(stream, 3); - stream.SaveToFile(dst, adSaveCreateOverWrite); - stream.Close(); - }); + UseObject("ADODB.Stream", function(stream) { + stream.Type = adTypeText; + stream.Charset = charset; + stream.Open(); + stream.WriteText(str); + stream = (new Converter()).repositionObject(stream, 3); + stream.SaveToFile(dst, adSaveCreateOverWrite); + stream.Close(); + }); // Set a result isCommited = true;