diff options
| author | Ryan Dahl <ry@tinyclouds.org> | 2019-05-14 17:14:08 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-14 17:14:08 -0400 |
| commit | 1b359f4106891f2f07c334da683822070b24374f (patch) | |
| tree | 8e8a704af3e0398a534621a4743d56a8ca71a3ea /prettier | |
| parent | e3e9269c76299df99975e17a04b4d1b1ca39dfcb (diff) | |
walk() should not use deprecated FileInfo.path (denoland/deno_std#398)
The walk() interface is change to return a WalkInfo object which
contains both the resolved filename and FileInfo object from stat.
The followSymlinks feature is disabled for now.
Original: https://github.com/denoland/deno_std/commit/07ca4f9629769a75bad11bb1059a7809d7f90db8
Diffstat (limited to 'prettier')
| -rwxr-xr-x | prettier/main.ts | 19 | ||||
| -rw-r--r-- | prettier/main_test.ts | 12 |
2 files changed, 15 insertions, 16 deletions
diff --git a/prettier/main.ts b/prettier/main.ts index a11501de1..0b5034c5f 100755 --- a/prettier/main.ts +++ b/prettier/main.ts @@ -12,9 +12,8 @@ // This script formats the given source files. If the files are omitted, it // formats the all files in the repository. const { args, exit, readFile, writeFile } = Deno; -type FileInfo = Deno.FileInfo; import { glob } from "../fs/glob.ts"; -import { walk } from "../fs/walk.ts"; +import { walk, WalkInfo } from "../fs/walk.ts"; import { parse } from "../flags/mod.ts"; import { prettier, prettierPlugins } from "./prettier.ts"; @@ -174,15 +173,15 @@ function selectParser(path: string): ParserLabel | null { * If paths are empty, then checks all the files. */ async function checkSourceFiles( - files: AsyncIterableIterator<FileInfo>, + files: AsyncIterableIterator<WalkInfo>, prettierOpts: PrettierOptions ): Promise<void> { const checks: Array<Promise<boolean>> = []; - for await (const file of files) { - const parser = selectParser(file.path); + for await (const { filename } of files) { + const parser = selectParser(filename); if (parser) { - checks.push(checkFile(file.path, parser, prettierOpts)); + checks.push(checkFile(filename, parser, prettierOpts)); } } @@ -202,15 +201,15 @@ async function checkSourceFiles( * If paths are empty, then formats all the files. */ async function formatSourceFiles( - files: AsyncIterableIterator<FileInfo>, + files: AsyncIterableIterator<WalkInfo>, prettierOpts: PrettierOptions ): Promise<void> { const formats: Array<Promise<void>> = []; - for await (const file of files) { - const parser = selectParser(file.path); + for await (const { filename } of files) { + const parser = selectParser(filename); if (parser) { - formats.push(formatFile(file.path, parser, prettierOpts)); + formats.push(formatFile(filename, parser, prettierOpts)); } } diff --git a/prettier/main_test.ts b/prettier/main_test.ts index 0c6653a3c..5a507afe7 100644 --- a/prettier/main_test.ts +++ b/prettier/main_test.ts @@ -63,8 +63,8 @@ test(async function testPrettierCheckAndFormatFiles(): Promise<void> { assertEquals(code, 0); assertEquals( normalizeOutput(stdout), - `Formatting ./prettier/testdata/0.ts -Formatting ./prettier/testdata/1.js` + `Formatting prettier/testdata/0.ts +Formatting prettier/testdata/1.js` ); var { code, stdout } = await run([...cmd, "--check", ...files]); @@ -87,10 +87,10 @@ test(async function testPrettierCheckAndFormatDirs(): Promise<void> { assertEquals(code, 0); assertEquals( normalizeOutput(stdout), - `Formatting ./prettier/testdata/bar/0.ts -Formatting ./prettier/testdata/bar/1.js -Formatting ./prettier/testdata/foo/0.ts -Formatting ./prettier/testdata/foo/1.js` + `Formatting prettier/testdata/bar/0.ts +Formatting prettier/testdata/bar/1.js +Formatting prettier/testdata/foo/0.ts +Formatting prettier/testdata/foo/1.js` ); var { code, stdout } = await run([...cmd, "--check", ...dirs]); |
