Skip to content

Commit fd1a4eb

Browse files
authored
Add Windows CI (#6)
* add windows build * operating system differences * hardcode regexp
1 parent 7fd4a9f commit fd1a4eb

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

.github/workflows/validate.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ on: [push]
44

55
jobs:
66
build:
7-
runs-on: ubuntu-latest
7+
strategy:
8+
matrix:
9+
platform: [ubuntu-latest, windows-latest]
10+
runs-on: ${{ matrix.platform }}
811
steps:
912
- uses: actions/checkout@v2
1013
- uses: actions/setup-node@v1

tests/index.test.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ const loader = require('../src/loader');
77

88
const source = fs.readFileSync(require.resolve('./fixture.md'), 'utf-8');
99

10+
function normalizeOperatingSystemPaths(s) {
11+
const cwd = process
12+
.cwd()
13+
.replace(/^[a-zA-Z]:/, '') // replace C: for Windows
14+
.split(path.sep)
15+
.join(path.posix.sep);
16+
17+
return s.replace(cwd, '.').replace(/\\r\\n/g, '\\n');
18+
}
19+
1020
function evaluate(output) {
1121
const {code} = babel.transformSync(output);
1222
const exports = {};
@@ -90,7 +100,7 @@ test('should fail build if invalid `schemaPath` is used', async () => {
90100
test('file output is correct', async () => {
91101
const output = await callLoader(options(), source);
92102

93-
expect(output.replace(process.cwd(), '.')).toMatchSnapshot();
103+
expect(normalizeOperatingSystemPaths(output)).toMatchSnapshot();
94104

95105
const page = evaluate(output);
96106

@@ -184,7 +194,7 @@ test('HMR', async () => {
184194
source
185195
);
186196

187-
expect(output.replace(process.cwd(), '.')).toMatchSnapshot();
197+
expect(normalizeOperatingSystemPaths(output)).toMatchSnapshot();
188198
});
189199

190200
test('mode="server"', async () => {

0 commit comments

Comments
 (0)