From 47a4e5f4caf0400c2ca95f0aae059bfdffe9ed08 Mon Sep 17 00:00:00 2001 From: dcode Date: Wed, 9 Dec 2020 22:47:51 +0100 Subject: [PATCH 1/2] Fix invalid and remove unnecessary string encoding arguments in asc --- cli/asc.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cli/asc.js b/cli/asc.js index fda8512943..1eb82f7b80 100644 --- a/cli/asc.js +++ b/cli/asc.js @@ -945,7 +945,7 @@ exports.main = function main(argv, options, callback) { let text; stats.readCount++; stats.readTime += measure(() => { - text = fs.readFileSync(name, { encoding: "utf8" }); + text = fs.readFileSync(name, "utf8"); }); return text; } catch (e) { @@ -961,10 +961,7 @@ exports.main = function main(argv, options, callback) { filename = path.basename(filename); const outputFilePath = path.join(dirPath, filename); if (!fs.existsSync(dirPath)) mkdirp(dirPath); - fs.writeFileSync( - outputFilePath, contents, - typeof contents === "string" ? { encoding: "utf8" } : void 0 - ); + fs.writeFileSync(outputFilePath, contents); }); return true; } catch (e) { @@ -993,7 +990,7 @@ exports.main = function main(argv, options, callback) { } stats.writeTime += measure(() => { if (typeof contents === "string") { - stdout.write(contents, { encoding: "utf8" }); + stdout.write(contents); } else { stdout.write(contents); } From baa992679a6b76ea4c9a7fe41c7652c39566f48e Mon Sep 17 00:00:00 2001 From: dcode Date: Wed, 9 Dec 2020 22:52:24 +0100 Subject: [PATCH 2/2] no need for a branch anymore --- cli/asc.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cli/asc.js b/cli/asc.js index 1eb82f7b80..ef26b5c99e 100644 --- a/cli/asc.js +++ b/cli/asc.js @@ -989,11 +989,7 @@ exports.main = function main(argv, options, callback) { writeStdout.used = true; } stats.writeTime += measure(() => { - if (typeof contents === "string") { - stdout.write(contents); - } else { - stdout.write(contents); - } + stdout.write(contents); }); } };