Skip to content

Commit

Permalink
fix: fix validateGeneratedTypes on Windows
Browse files Browse the repository at this point in the history
* chore: run tests on multiple operating systems
* chore: fix prettier end-of-line issue on Windows
  • Loading branch information
schiller-manuel committed Nov 29, 2023
1 parent f51309e commit bd7df0e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.js
Expand Up @@ -16,6 +16,12 @@ module.exports = {
rules: {
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/explicit-module-boundary-types": 0,
"prettier/prettier": [
"error",
{
endOfLine: "auto",
},
],
},
ignorePatterns: ["lib", "coverage"],
};
19 changes: 15 additions & 4 deletions .github/workflows/tests.yaml
Expand Up @@ -9,12 +9,23 @@ on:

jobs:
test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
node_version:
- 20
architecture:
- x64
name: tests on ${{ matrix.node_version }} - ${{ matrix.architecture }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: ${{ matrix.node_version }}
architecture: ${{ matrix.architecture }}
- run: yarn
- run: chmod +x ./bin/run
- run: yarn test:ci
Expand Down
10 changes: 7 additions & 3 deletions src/core/validateGeneratedTypes.ts
Expand Up @@ -4,7 +4,7 @@ import {
createVirtualTypeScriptEnvironment,
} from "@typescript/vfs";
import ts from "typescript";
import { join } from "path";
import { join, sep, posix } from "path";
import { resolveDefaultProperties } from "../utils/resolveDefaultProperties";
import { fixOptionalAny } from "../utils/fixOptionalAny";
interface File {
Expand Down Expand Up @@ -37,7 +37,7 @@ export function validateGeneratedTypes({
const fsMap = createDefaultMapFromNodeModules({
target: compilerOptions.target,
});
const projectRoot = process.cwd();
const projectRoot = makePosixPath(process.cwd());
const src = fixOptionalAny(
skipParseJSDoc
? sourceTypes.sourceText
Expand Down Expand Up @@ -116,5 +116,9 @@ function getDetails(file: ts.SourceFile, line: number) {
}

function getPath(file: File) {
return join(process.cwd(), file.relativePath);
return makePosixPath(join(process.cwd(), file.relativePath));
}

function makePosixPath(str: string) {
return str.split(sep).join(posix.sep);
}

0 comments on commit bd7df0e

Please sign in to comment.