refactor: print trailing new line when outputting JSON (#6186)

* refactor(core): print trailing new line when writing translation

* Print these as well
This commit is contained in:
Joshua Chen 2021-12-24 22:11:35 +08:00 committed by GitHub
parent a17deb6aa2
commit 1460f867d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View file

@ -66,7 +66,7 @@ function generateTemplateExample(template) {
// rewrite the package.json file with the new edit // rewrite the package.json file with the new edit
writeFileSync( writeFileSync(
`./examples/${template}/package.json`, `./examples/${template}/package.json`,
JSON.stringify(templatePackageJson, null, 2), `${JSON.stringify(templatePackageJson, null, 2)}\n`,
); );
// create sandbox.config.json file at the root of template // create sandbox.config.json file at the root of template
@ -82,7 +82,7 @@ function generateTemplateExample(template) {
}; };
writeFileSync( writeFileSync(
`./examples/${template}/sandbox.config.json`, `./examples/${template}/sandbox.config.json`,
JSON.stringify(codeSanboxConfig, null, 2), `${JSON.stringify(codeSanboxConfig, null, 2)}\n`,
); );
const stackBlitzConfig = { const stackBlitzConfig = {
@ -91,7 +91,7 @@ function generateTemplateExample(template) {
}; };
writeFileSync( writeFileSync(
`./examples/${template}/.stackblitzrc`, `./examples/${template}/.stackblitzrc`,
JSON.stringify(stackBlitzConfig, null, 2), `${JSON.stringify(stackBlitzConfig, null, 2)}\n`,
); );
console.log(`Generated example for template ${template}`); console.log(`Generated example for template ${template}`);

View file

@ -35,7 +35,7 @@ async function updatePkg(pkgPath: string, obj: Record<string, unknown>) {
const pkg = JSON.parse(content); const pkg = JSON.parse(content);
const newPkg = Object.assign(pkg, obj); const newPkg = Object.assign(pkg, obj);
await fs.outputFile(pkgPath, JSON.stringify(newPkg, null, 2)); await fs.outputFile(pkgPath, `${JSON.stringify(newPkg, null, 2)}\n`);
} }
function readTemplates(templatesDir: string) { function readTemplates(templatesDir: string) {

View file

@ -133,7 +133,7 @@ Maybe you should remove them? ${unknownKeys}`;
filePath, filePath,
)}.`; )}.`;
await fs.ensureDir(path.dirname(filePath)); await fs.ensureDir(path.dirname(filePath));
await fs.writeFile(filePath, JSON.stringify(mergedContent, null, 2)); await fs.writeFile(filePath, `${JSON.stringify(mergedContent, null, 2)}\n`);
} }
} }