Skip to content

Commit d143bee

Browse files
show relative filepaths
1 parent 1846e4d commit d143bee

7 files changed

Lines changed: 41 additions & 27 deletions

File tree

out/snippetFormatter.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

out/talonFormatter.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

out/treeSitterFormatter.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cursorless/talon-tools",
3-
"version": "0.1.8",
3+
"version": "0.1.9",
44
"description": "Linting and formatting tools for Talon and Cursorless",
55
"author": "Cursorless Dev",
66
"license": "MIT",

src/cli/cli.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { getOptionsFromConfig } from "../util/getOptionsFromConfig.js";
1111
import { isMissingFileError } from "../util/isMissingFileError.js";
1212
import { parseArgs } from "../util/parseArgs.js";
1313
import { parseFilePatterns } from "../util/parseFilePatterns.js";
14+
import { normalizeToPosix } from "../util/normalizeToPosix.js";
1415
import { printHelp } from "../util/printHelp.js";
1516
import { printVersion } from "../util/printVersion.js";
1617
import { setExitCode } from "../util/setExitCode.js";
@@ -180,7 +181,7 @@ export async function formatFile({
180181
return false;
181182
}
182183

183-
logger.log(filePath);
184+
logger.log(getDisplayPath(filePath));
184185

185186
if (!check) {
186187
await fs.writeFile(filePath, formatted, "utf8");
@@ -201,6 +202,10 @@ export async function formatFile({
201202
}
202203
}
203204

205+
function getDisplayPath(filePath: string): string {
206+
return normalizeToPosix(path.relative(process.cwd(), filePath));
207+
}
208+
204209
interface MainFormatStdinArgs {
205210
cli: CLI;
206211
logger: Logger;

src/test/cli.test.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import type {
1616
import { EXIT_FAIL, EXIT_OK } from "../util/constants.js";
1717
import { createLogger } from "../util/createLogger.js";
1818
import { getDefaultArguments } from "../util/getDefaultArguments.js";
19+
import { normalizeToPosix } from "../util/normalizeToPosix.js";
1920
import { parseArgs } from "../util/parseArgs.js";
2021
import { printHelp } from "../util/printHelp.js";
2122

@@ -68,7 +69,7 @@ suite("CLI", () => {
6869
assert.equal(didChange, true);
6970
assert.equal(actual, "content");
7071
assert.deepEqual(logger.getEntries(), [
71-
{ level: "log", message: fileName },
72+
{ level: "log", message: getDisplayPath(fileName) },
7273
]);
7374
} finally {
7475
await cleanupTempFile(fileName);
@@ -331,7 +332,7 @@ suite("CLI", () => {
331332
assert.equal(stdout.text, "");
332333
assert.equal(stderr.text, "");
333334
assert.deepEqual(logger.getEntries(), [
334-
{ level: "log", message: fileName },
335+
{ level: "log", message: getDisplayPath(fileName) },
335336
]);
336337
} finally {
337338
await cleanupTempFile(fileName);
@@ -359,7 +360,11 @@ suite("CLI", () => {
359360
assert.equal(output.result, EXIT_FAIL);
360361
assert.equal(
361362
output.stdoutText,
362-
["Checking formatting...", `${fileName}`, ""].join("\n"),
363+
[
364+
"Checking formatting...",
365+
`${getDisplayPath(fileName)}`,
366+
"",
367+
].join("\n"),
363368
);
364369
assert.equal(
365370
output.stderrText,
@@ -576,7 +581,7 @@ suite("CLI", () => {
576581
assert.equal(output.result, true);
577582
assert.equal(output.text, "");
578583
assert.deepEqual(logger.getEntries(), [
579-
{ level: "log", message: fileName },
584+
{ level: "log", message: getDisplayPath(fileName) },
580585
]);
581586
} finally {
582587
await cleanupTempFile(fileName);
@@ -714,3 +719,7 @@ function getArguments(args: Partial<ParsedArgs>) {
714719
...args,
715720
};
716721
}
722+
723+
function getDisplayPath(filePath: string): string {
724+
return normalizeToPosix(path.relative(process.cwd(), filePath));
725+
}

0 commit comments

Comments
 (0)