Skip to content

Commit b3e46f4

Browse files
Merge branch 'main' into fix/ensure-file-sync
2 parents a093a78 + 1b2e0b3 commit b3e46f4

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

chompfile.toml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
version = 0.1
22

3+
default-task = 'build'
4+
35
[[task]]
46
name = 'build'
57
run = 'tsup src/loader.ts --format esm,cjs --dts'
6-
deps = 'npm:install'
8+
dep = 'src/loader.ts'
9+
target = 'dist/loader.js'
10+
11+
[[task]]
12+
name = 'npm:install'
13+
run = 'npm install'
14+
dep = 'package.json'
15+
target = 'package-lock.json'
716

817
[[task]]
918
name = 'clean'
@@ -21,14 +30,10 @@ run = 'commitlint --edit $1'
2130
name = 'default'
2231
run = 'npm install --no-save react-dom@17.0.2 @teleporthq/teleport-project-generator-react@0.25.4 @teleporthq/teleport-project-generator-preact@0.20.0 chalk express morgan react-router@5.2.1 react-router-dom@5.2.1 && node tests/e2e/test.js'
2332

24-
[[task]]
25-
name = 'npm:install'
26-
run = 'npm install'
27-
deps = ['package.json']
28-
2933
[[task]]
3034
name = 'lint'
3135
run = 'eslint src --ext .ts'
36+
deps = ['src/#.ts', 'tests/loader.test.ts']
3237

3338
[[task]]
3439
name = 'lint-fix'
@@ -37,6 +42,7 @@ run = 'chomp lint --fix'
3742
[[task]]
3843
name = 'pre-commit'
3944
run = 'lint-staged'
45+
deps = ['src/#.ts', 'tests/loader.test.ts']
4046

4147
[[task]]
4248
name = 'prepare'
@@ -77,3 +83,4 @@ run = 'vitest run'
7783
[[task]]
7884
name = 'typecheck'
7985
run = 'tsc --noEmit'
86+
deps = ['src/#.ts']

tests/loader.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import * as global from "node:fs";
2+
import { join } from "node:path";
13
import { vi, test, expect } from 'vitest'
24
import { ImportMap } from "@jspm/import-map";
35

@@ -9,6 +11,8 @@ import {
911
getLastPart,
1012
getPackageNameVersionFromUrl,
1113
getVersion,
14+
parseModule,
15+
ensureFileSync,
1216
} from "../src/loader"
1317

1418
vi.mock('url', () => ({
@@ -74,3 +78,12 @@ test('getPackageNameVersionFromUrl', () => {
7478
version: '1.10.0',
7579
});
7680
});
81+
82+
83+
test('should return the specifier if the module path is a node or file protocol', async () => {
84+
const specifier = 'my-module';
85+
const modulePath1 = 'node:fs';
86+
const modulePath2 = 'file:///path/to/my/module.js';
87+
expect(await parseModule(specifier, modulePath1)).toEqual(specifier);
88+
expect(await parseModule(specifier, modulePath2)).toEqual(specifier);
89+
});

0 commit comments

Comments
 (0)