File tree Expand file tree Collapse file tree 3 files changed +27
-7
lines changed
Expand file tree Collapse file tree 3 files changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,14 @@ version = 0.1
33[[task ]]
44name = ' build'
55run = ' tsup src/loader.ts --format esm,cjs --dts'
6- deps = ' npm:install'
6+ dep = ' src/loader.ts'
7+ target = ' dist/loader.js'
8+
9+ [[task ]]
10+ name = ' npm:install'
11+ run = ' npm install'
12+ dep = ' package.json'
13+ target = ' package-lock.json'
714
815[[task ]]
916name = ' clean'
@@ -21,14 +28,10 @@ run = 'commitlint --edit $1'
2128name = ' default'
2229run = ' 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'
2330
24- [[task ]]
25- name = ' npm:install'
26- run = ' npm install'
27- deps = [' package.json' ]
28-
2931[[task ]]
3032name = ' lint'
3133run = ' eslint src --ext .ts'
34+ deps = [' src/#.ts' , ' tests/loader.test.ts' ]
3235
3336[[task ]]
3437name = ' lint-fix'
@@ -37,6 +40,9 @@ run = 'chomp lint --fix'
3740[[task ]]
3841name = ' pre-commit'
3942run = ' lint-staged'
43+ deps = [' src/#.ts' , ' tests/loader.test.ts' ]
44+
45+ [[task ]]
4046
4147[[task ]]
4248name = ' prepare'
@@ -77,3 +83,4 @@ run = 'vitest run'
7783[[task ]]
7884name = ' typecheck'
7985run = ' tsc --noEmit'
86+ deps = [' src/#.ts' ]
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ const cacheMap = new Map();
1313 * @description a convenience function to ensure a file exists
1414 * @param path
1515 */
16- function ensureFileSync ( path : string ) {
16+ export function ensureFileSync ( path : string ) {
1717 try {
1818 accessSync ( path ) ;
1919 } catch ( err ) {
Original file line number Diff line number Diff line change 1+ import * as global from "node:fs" ;
2+ import { join } from "node:path" ;
13import { vi , test , expect } from 'vitest'
24import { 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
1418vi . 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+ } ) ;
You can’t perform that action at this time.
0 commit comments