Fix trailing new line

This commit is contained in:
Michaël Lemaire 2021-09-05 23:58:08 +02:00
parent 98635fca28
commit de06f0839e
4 changed files with 20 additions and 13 deletions

View file

@ -42,6 +42,13 @@ export class ProjectNormalizer {
await this.formatPath(path);
}
async writeLines(path: string, lines: string[]) {
await this.sys.writeTextFile(
path,
lines.concat("").join("\n"),
);
}
async formatPath(path: string) {
await this.sys.run({
cmd: ["./run", "fmt", "-q", path],
@ -49,7 +56,7 @@ export class ProjectNormalizer {
}
async updateRunScript() {
await this.sys.writeTextFile(
await this.writeLines(
"run",
[
`#!/bin/sh`,
@ -71,7 +78,7 @@ export class ProjectNormalizer {
``,
`denoargs="$(cat config/$denocmd.flags 2> /dev/null) $denoargs $@"`,
`exec deno $denocmd $denoargs`,
].join("\n"),
],
);
await this.sys.chmod("run", 0o755);
}
@ -86,7 +93,7 @@ export class ProjectNormalizer {
}
async updateEditorConfig() {
await this.sys.writeTextFile(
await this.writeLines(
".editorconfig",
[
`root = true`,
@ -98,7 +105,7 @@ export class ProjectNormalizer {
`indent_style = space`,
`indent_size = 2`,
`trim_trailing_whitespace = true`,
].join("\n"),
],
);
}
@ -168,25 +175,25 @@ export class ProjectNormalizer {
}
async updateGitIgnore() {
await this.sys.writeTextFile(
await this.writeLines(
".gitignore",
[
`deno.d.ts`,
`.vscode`,
`.local`,
].join("\n"),
],
);
}
async updateGitHooks() {
await this.sys.writeTextFile(
await this.writeLines(
".git/hooks/pre-commit",
[
`#!/bin/sh`,
`set -e`,
`./run fmt --check`,
`./run test`,
].join("\n"),
],
);
await this.sys.chmod(".git/hooks/pre-commit", 0o755);
}
@ -203,13 +210,13 @@ export class ProjectNormalizer {
}
}
}
await this.sys.writeTextFile(
await this.writeLines(
"README.md",
[
`# typescript/${project}`,
`[![Build Status](https://thunderk.visualstudio.com/typescript/_apis/build/status/${project}?branchName=master)](https://dev.azure.com/thunderk/typescript/_build?pipelineNameFilter=${project})`,
sections,
].join("\n"),
],
);
await this.formatPath("README.md");
}