Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

Commit 9c26a6b

Browse files
ci: use node 12 (#46)
1 parent c289a76 commit 9c26a6b

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

.github/workflows/test.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jobs:
99
name: Test
1010
runs-on: ubuntu-latest
1111
timeout-minutes: 10
12+
1213
steps:
1314
- name: Checkout
1415
uses: actions/checkout@v3
@@ -19,8 +20,9 @@ jobs:
1920
node-version-file: '.nvmrc'
2021

2122
- name: Setup pnpm
22-
uses: pnpm/action-setup@v2
23+
uses: pnpm/action-setup@v2.4.0
2324
with:
25+
standalone: true
2426
version: 8
2527
run_install: true
2628

@@ -30,5 +32,16 @@ jobs:
3032
- name: Type check
3133
run: pnpm type-check
3234

35+
- name: Build
36+
run: pnpm build
37+
3338
- name: Test
3439
run: pnpm test
40+
41+
- name: Use Node.js 12
42+
uses: actions/setup-node@v3
43+
with:
44+
node-version: '12'
45+
46+
- name: Test with Node v12
47+
run: pnpm test

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"build": "pkgroll --target node12.20 --minify",
3131
"lint": "eslint --cache .",
3232
"type-check": "tsc --noEmit",
33-
"test": "pnpm build && tsx --no-cache tests",
33+
"test": "tsx --no-cache tests",
3434
"dev": "tsx watch --no-cache --conditions=development tests",
3535
"prepack": "pnpm build && clean-pkg-json"
3636
},

tests/specs/source-maps.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
import { spawnSync } from 'child_process';
22
import path from 'path';
3+
import { promises as fs } from 'fs';
34
import { testSuite, expect } from 'manten';
45
import { createFixture } from 'fs-fixture';
56
import {
67
transformSync,
78
installSourceMapSupport,
89
} from '#esbuild-kit/core-utils';
910

11+
const isNode12 = process.version.startsWith('v12.');
12+
1013
const applySourceMap = installSourceMapSupport();
1114

1215
export default testSuite(({ describe }) => {
1316
describe('source map', ({ test }) => {
14-
test('sourcemap file', async () => {
17+
test('sourcemap file', async ({ onTestFinish }) => {
1518
const rawFile = 'raw.js';
1619
const code = 'let nameInError;\n\n\n nameInError();';
1720
const transformedFile = 'transformed.mts';
@@ -26,16 +29,27 @@ export default testSuite(({ describe }) => {
2629
[transformedFile]: applySourceMap(transformed, ''),
2730
});
2831

32+
onTestFinish(async () => {
33+
if (isNode12) {
34+
await fs.rmdir(fixture.path, {
35+
recursive: true,
36+
});
37+
} else {
38+
await fixture.rm();
39+
}
40+
});
41+
2942
const expected = spawnSync(process.execPath, [path.join(fixture.path, rawFile)]);
3043
const received = spawnSync(process.execPath, ['--enable-source-maps', path.join(fixture.path, transformedFile)]);
3144

32-
await fixture.rm();
33-
3445
const stderrReceived = received.stderr.toString();
3546
expect(stderrReceived).toMatch('nameInError');
3647

37-
const errorPosition = expected.stderr.toString().match(new RegExp(`${rawFile}(:\\d+:\\d+)`));
38-
expect(stderrReceived).toMatch(transformedFile + errorPosition![1]);
48+
// Node 12 doesn't support native source maps
49+
if (!isNode12) {
50+
const errorPosition = expected.stderr.toString().match(new RegExp(`${rawFile}(:\\d+:\\d+)`));
51+
expect(stderrReceived).toMatch(transformedFile + errorPosition![1]);
52+
}
3953
});
4054

4155
test('path is same for windows', async () => {

0 commit comments

Comments
 (0)