From ef88e3795fdf8595a71a37020956d05561b1f467 Mon Sep 17 00:00:00 2001 From: Milos Djermanovic Date: Tue, 18 Jun 2024 16:44:59 +0200 Subject: [PATCH] chore: fix writing files in tools (#611) --- tools/create-test.js | 5 +++-- tools/update-tests.js | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/create-test.js b/tools/create-test.js index 034b423c..e9a3f24c 100644 --- a/tools/create-test.js +++ b/tools/create-test.js @@ -18,6 +18,7 @@ import shelljs from "shelljs"; import { parse } from "../espree.js"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import fs from "node:fs"; //------------------------------------------------------------------------------ // Initialization @@ -119,11 +120,11 @@ code.forEach((source, index) => { recursivelyRemoveStartAndEnd(result); - sourceCode.to(testSourceFilename); + fs.writeFileSync(testSourceFilename, sourceCode); let resultCode = `export default ${JSON.stringify(result, (key, value) => ((typeof value === "bigint") ? `bigint<${value}n>` : value), 4)};`; resultCode = resultCode.replace(/"bigint<(\d+n)>"/gu, "$1"); - resultCode.to(testResultFilename); + fs.writeFileSync(testResultFilename, resultCode); }); diff --git a/tools/update-tests.js b/tools/update-tests.js index 48d74db5..b544a5b9 100644 --- a/tools/update-tests.js +++ b/tools/update-tests.js @@ -16,6 +16,7 @@ import shelljs from "shelljs"; import tester from "../tests/lib/tester.js"; import path from "node:path"; import { fileURLToPath } from "node:url"; +import fs from "node:fs"; //------------------------------------------------------------------------------ // Helpers @@ -54,7 +55,7 @@ function getLibraryFilenames(directory) { * @returns {void} */ function outputResult(result, testResultFilename) { - `export default ${tester.getAstCode(result)};`.to(testResultFilename); + fs.writeFileSync(testResultFilename, `export default ${tester.getAstCode(result)};`); } //------------------------------------------------------------------------------ @@ -76,7 +77,7 @@ libraryFiles.forEach(filename => { tokens: true }); - JSON.stringify(result).to(testResultFilename); + fs.writeFileSync(testResultFilename, JSON.stringify(result)); }); // update all tests in ecma-features