fix(update): update script actually supports comments in jsonc (#1591)
This commit is contained in:
+12
-2
@@ -356,14 +356,24 @@ Deno.test("fresh-update", async function fn(t) {
|
||||
);
|
||||
});
|
||||
|
||||
const comment = "// This is a test comment";
|
||||
const regex = /("preact": "https:\/\/esm.sh\/preact@[\d.]+",\n)/;
|
||||
const originalName = `${tmpDirName}/deno.json`;
|
||||
const updatedName = `${originalName}c`;
|
||||
await t.step("execute update command deno.jsonc support", async () => {
|
||||
try {
|
||||
Deno.renameSync(`${tmpDirName}/deno.json`, `${tmpDirName}/deno.jsonc`);
|
||||
Deno.renameSync(originalName, updatedName);
|
||||
let denoJsonText = await Deno.readTextFile(updatedName);
|
||||
denoJsonText = denoJsonText.replace(regex, `$1${comment}\n`);
|
||||
await Deno.writeTextFile(updatedName, denoJsonText);
|
||||
await updateAndVerify(
|
||||
/The manifest has been generated for \d+ routes and \d+ islands./,
|
||||
);
|
||||
} finally {
|
||||
Deno.renameSync(`${tmpDirName}/deno.jsonc`, `${tmpDirName}/deno.json`);
|
||||
let denoJsonText = await Deno.readTextFile(updatedName);
|
||||
denoJsonText = denoJsonText.replace(new RegExp(`\n${comment}\n`), "\n");
|
||||
await Deno.writeTextFile(updatedName, denoJsonText);
|
||||
Deno.renameSync(updatedName, originalName);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user