Skip to content

Commit

Permalink
Fix: Revert unix style warning (#4173)
Browse files Browse the repository at this point in the history
This actually prevent passing windows style path via the CLI in emitter
options which is really a blocker
  • Loading branch information
timotheeguerin committed Aug 13, 2024
1 parent f62225b commit d698b51
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
changeKind: fix
packages:
- "@typespec/compiler"
---

Fix: Revert `unix-style` warning that was preventing windows path via the CLI as well
14 changes: 7 additions & 7 deletions packages/compiler/src/config/config-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,13 @@ function validatePathAbsolute(
target: target === NoTarget ? target : getLocationInYamlScript(target.file, target.path),
});
}
if (path.includes("\\")) {
return createDiagnostic({
code: "path-unix-style",
format: { path },
target: target === NoTarget ? target : getLocationInYamlScript(target.file, target.path),
});
}
// if (path.includes("\\")) {
// return createDiagnostic({
// code: "path-unix-style",
// format: { path },
// target: target === NoTarget ? target : getLocationInYamlScript(target.file, target.path),
// });
// }

return undefined;
}
25 changes: 8 additions & 17 deletions packages/compiler/src/core/schema-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ function absolutePathStatus(path: string): "valid" | "not-absolute" | "windows-s
if (path.startsWith(".") || !isPathAbsolute(path)) {
return "not-absolute";
}
if (path.includes("\\")) {
return "windows-style";
}
// if (path.includes("\\")) {
// return "windows-style";
// }
return "valid";
}

Expand Down Expand Up @@ -75,20 +75,11 @@ function ajvErrorToDiagnostic(
const tspTarget = resolveTarget(error, target);
if (error.params.format === "absolute-path") {
const value = getErrorValue(obj, error) as any;
const status = absolutePathStatus(value);
if (status === "windows-style") {
return createDiagnostic({
code: "path-unix-style",
format: { path: value },
target: tspTarget,
});
} else {
return createDiagnostic({
code: "config-path-absolute",
format: { path: value },
target: tspTarget,
});
}
return createDiagnostic({
code: "config-path-absolute",
format: { path: value },
target: tspTarget,
});
}

const messageLines = [`Schema violation: ${error.message} (${error.instancePath || "/"})`];
Expand Down
3 changes: 2 additions & 1 deletion packages/compiler/test/core/emitter-options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ describe("compiler: emitter options", () => {
});
});

it("emit diagnostic if passing windows style path", async () => {
// This was disabled due to making it impossible to use windows path via the cli https://github.com/microsoft/typespec/pull/4173
it.skip("emit diagnostic if passing windows style path", async () => {
const diagnostics = await diagnoseEmitterOptions({
"asset-dir": "C:\\abc\\def",
});
Expand Down

0 comments on commit d698b51

Please sign in to comment.