diff options
| author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2019-03-24 16:26:47 +0100 |
|---|---|---|
| committer | Ryan Dahl <ry@tinyclouds.org> | 2019-03-24 11:26:47 -0400 |
| commit | 4347148d507868d508782f154f2b49dbe6ea359b (patch) | |
| tree | 70a8304f70a8ac24a9e2253960bf0b4d3e0bdaf8 | |
| parent | aae6ea51a496301011c41a874a25b77596d5c560 (diff) | |
Fix prettier check in empty files (denoland/deno_std#302)
Original: https://github.com/denoland/deno_std/commit/e5a493e9e8df80abec51c06958dea755e19c40fd
| -rwxr-xr-x | prettier/main.ts | 4 | ||||
| -rw-r--r-- | prettier/main_test.ts | 6 | ||||
| -rw-r--r-- | prettier/testdata/2.ts | 0 |
3 files changed, 7 insertions, 3 deletions
diff --git a/prettier/main.ts b/prettier/main.ts index a5e11e79f..f4a2232cc 100755 --- a/prettier/main.ts +++ b/prettier/main.ts @@ -107,8 +107,8 @@ async function checkFile( const text = await readFileIfExists(filename); if (!text) { - // The file is deleted. Skip. - return; + // The file is empty. Skip. + return true; } const formatted = prettier.check(text, { diff --git a/prettier/main_test.ts b/prettier/main_test.ts index 0d6015080..10ad79e36 100644 --- a/prettier/main_test.ts +++ b/prettier/main_test.ts @@ -48,7 +48,11 @@ async function clearTestdataChanges(): Promise<void> { test(async function testPrettierCheckAndFormatFiles() { await clearTestdataChanges(); - const files = [join(testdata, "0.ts"), join(testdata, "1.js")]; + const files = [ + join(testdata, "0.ts"), + join(testdata, "1.js"), + join(testdata, "2.ts") + ]; var { code, stdout } = await run([...cmd, "--check", ...files]); assertEquals(code, 1); diff --git a/prettier/testdata/2.ts b/prettier/testdata/2.ts new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/prettier/testdata/2.ts |
