From db835c4122a2b238b149c19e0451956dc7630b1f Mon Sep 17 00:00:00 2001 From: frankpagan <frank@cocreate.app> Date: Thu, 28 Dec 2023 22:40:01 -0500 Subject: [PATCH 1/3] fix: fileUploader handle argv --- src/index.js | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/index.js b/src/index.js index 75e7472..a7ad761 100644 --- a/src/index.js +++ b/src/index.js @@ -58,29 +58,34 @@ class ModuleGenerator { } class fileUploader { - constructor(env) { + constructor(env, argv) { this.env = env; this.isWatching = false; + this.isWatch = argv.watch === true; } apply(compiler) { - if (this.env.beforeCompilation) { - // Directly perform upload here - upload(process.cwd(), ['../', '-w']); - } + if (this.isWatch) { - if (this.env.afterCompilation) { - compiler.hooks.emit.tapAsync('watchFiles', (compilation, callback) => { - if (!this.isWatching) { - this.isWatching = true; - upload(process.cwd(), ['../', '-w']); - } - callback(); - }); + if (this.env.beforeCompilation) { + // Directly perform upload here + upload(process.cwd(), ['../', '-w']); + } + + if (this.env.afterCompilation) { + compiler.hooks.emit.tapAsync('watchFiles', (compilation, callback) => { + if (!this.isWatching) { + this.isWatching = true; + upload(process.cwd(), ['../', '-w']); + } + callback(); + }); + } } } } + class SymlinkCreator { constructor(options) { // Store options if necessary, or just hard-code paths From 74134a6066d50a486a92ca13c7ba33090fdc190a Mon Sep 17 00:00:00 2001 From: frankpagan <frank@cocreate.app> Date: Thu, 28 Dec 2023 22:41:50 -0500 Subject: [PATCH 2/3] feat: loader to handle special characters --- src/replace-unicode.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/replace-unicode.js diff --git a/src/replace-unicode.js b/src/replace-unicode.js new file mode 100644 index 0000000..3838f22 --- /dev/null +++ b/src/replace-unicode.js @@ -0,0 +1,21 @@ +module.exports = function (source) { + return source.replace(/\$'/g, '\\u0024\''); + + // const specialChars = /[\0\x08\x09\x1a\n\r"'\\\%\$]/g; // Add or remove characters based on your needs + // const replacements = { + // // "\0": "\\0", + // // "\x08": "\\b", + // // "\x09": "\\t", + // // "\x1a": "\\z", + // // "\n": "\\n", + // // "\r": "\\r", + // // "\"": "\\\"", + // // "'": "\\'", + // // "\\": "\\\\", + // // "%": "\\%", + // "$": "\\$" // Escape for MongoDB and others + // // ... add more replacements as needed for other databases + // }; + + // return source.replace(specialChars, (char) => (replacements[char] || char)); +}; \ No newline at end of file From 15074750a5f9c473841f33654b9890ce01d76e8e Mon Sep 17 00:00:00 2001 From: frankpagan <frank@cocreate.app> Date: Thu, 28 Dec 2023 23:08:29 -0500 Subject: [PATCH 3/3] fix: update fileUploader to pascalCase FileUploader --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index a7ad761..1d4df40 100644 --- a/src/index.js +++ b/src/index.js @@ -57,7 +57,7 @@ class ModuleGenerator { } } -class fileUploader { +class FileUploader { constructor(env, argv) { this.env = env; this.isWatching = false; @@ -121,4 +121,4 @@ class SymlinkCreator { } } -module.exports = { ModuleGenerator, fileUploader, SymlinkCreator }; +module.exports = { ModuleGenerator, FileUploader, SymlinkCreator };