Skip to content

Commit 8151444

Browse files
Merge pull request #8 from allegro/fix_windows_paths
Fix windows paths
2 parents 0c2cc8b + a614072 commit 8151444

File tree

13 files changed

+11006
-1783
lines changed

13 files changed

+11006
-1783
lines changed

.github/workflows/ci.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
name: CI
22

33
on:
4-
[push, pull_request]
4+
[push]
55

66
jobs:
77
build:
8-
runs-on: ubuntu-latest
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
os: [ubuntu-latest, windows-latest]
912

1013
steps:
1114
- uses: actions/checkout@v2

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project
66
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.1.1] - 2021-08-29
9+
10+
### Fixed
11+
12+
- Path features not working on Windows machines
13+
814
## [1.1.0] - 2021-06-15
915

1016
### Added

e2e/compile-time-tool-tests/compile-time-tool.spec.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import execa from 'execa';
2-
import { join } from 'path';
2+
import path, { join } from 'path';
33

44
const runInPath = async (path: string): Promise<string> => {
55
const cwd = process.cwd();
6-
const cli = join(cwd, 'dist/compile-time-tool/cli.js');
6+
const cli = join(cwd, 'dist', 'compile-time-tool', 'cli.js');
77

88
process.chdir(path);
99
return execa('node', [cli], {
@@ -23,12 +23,12 @@ const runInPath = async (path: string): Promise<string> => {
2323

2424
test('files are detected correctly', async () => {
2525
jest.setTimeout(20000);
26-
const path = process.cwd() + '/e2e/compile-time-tool-tests/repository';
26+
const executionPath = path.join(process.cwd(), 'e2e', 'compile-time-tool-tests', 'repository');
2727

28-
await runInPath(path).then((stdout) => {
28+
await runInPath(executionPath).then((stdout) => {
2929
expect(stdout).toMatch(/notOnPath.ts/);
3030
expect(stdout).toMatch(/onPath.ts/);
31-
expect(stdout).toMatch(/TS2532: Object is possibly 'undefined'/);
31+
expect(stdout).toMatch(/TS2532: Object is possibly \\?\\?'undefined\\?\\?'/);
3232
expect(stdout).toMatch(/Found 2 strict files/);
3333
expect(stdout).toMatch(/2 errors found/);
3434
});

e2e/plugin-tests/tests/twoFilesCheckedAtTheSameTime.ts

+18-7
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ function findResponse(responses: ServerResponse[], eventName: string) {
2525
}
2626

2727
async function run(server: TSServer) {
28-
const rootPath = path.resolve(__dirname, '../project-fixture/');
29-
const file = path.resolve(__dirname, '../project-fixture/' + 'src/notOnPath.ts');
30-
const otherFile = path.resolve(__dirname, '../project-fixture/' + 'src/otherFileNotOnPath.ts');
28+
const projectFixture = path.join('..', 'project-fixture');
29+
const rootPath = path.resolve(__dirname, projectFixture);
30+
const file = path.resolve(__dirname, path.join(projectFixture, 'src', 'notOnPath.ts'));
31+
const otherFile = path.resolve(
32+
__dirname,
33+
path.join(projectFixture, 'src', 'otherFileNotOnPath.ts'),
34+
);
3135

3236
// open two files
3337
server.send({
@@ -62,14 +66,21 @@ async function run(server: TSServer) {
6266

6367
return server.close().then(() => {
6468
const semanticDiagEvent = findResponse(server.responses, 'semanticDiag');
65-
const fileEvent = semanticDiagEvent.filter((it) => it.body.file === file)[0];
66-
const otherFileEvent = semanticDiagEvent.filter((it) => it.body.file === otherFile)[0];
69+
const fileEvent = semanticDiagEvent.find((it) => toFileSystemSlash(it.body.file) === file);
70+
const otherFileEvent = semanticDiagEvent.find(
71+
(it) => toFileSystemSlash(it.body.file) === otherFile,
72+
);
6773

6874
assert(!!fileEvent);
6975
assert(!!otherFileEvent);
70-
assert.strictEqual(fileEvent.body.diagnostics.length, 1);
71-
assert.strictEqual(otherFileEvent.body.diagnostics.length, 0);
76+
77+
assert.strictEqual(fileEvent!.body.diagnostics.length, 1);
78+
assert.strictEqual(otherFileEvent!.body.diagnostics.length, 0);
7279
});
7380
}
7481

7582
module.exports = run;
83+
84+
function toFileSystemSlash(file: string): string {
85+
return file.split('/').join(path.sep);
86+
}

0 commit comments

Comments
 (0)