Skip to content

Commit 7f42dc8

Browse files
committed
fix: api rewrite 🫠 😂
1 parent de60629 commit 7f42dc8

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

src/__tests__/logger.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ import { logger } from '../logger';
33
test('logger works', () => {
44
const mockDebug = jest.spyOn(console, 'debug');
55
const mockError = jest.spyOn(console, 'error');
6-
const mockInfo = jest.spyOn(console, 'info');
76
const log = logger({ file: 'test', isLogging: true });
87
log.debug('debug');
98
log.error('error');
10-
log.info('info');
119
expect(mockDebug).toBeCalledWith('jspm:[test]: debug');
1210
expect(mockError).toBeCalledWith('jspm:[test]: error');
13-
expect(mockInfo).toBeCalledWith('jspm:[test]: info');
1411
})

src/config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ export const root = fileURLToPath(new URL(".", rootUrl));
1616
export const cacheMap = new Map();
1717
export const nodeImportMapPath = join(root, "node.importmap");
1818
export const cache = join(root, ".cache");
19-
export const map = existsSync(nodeImportMapPath) ? JSON.parse(readFileSync(nodeImportMapPath, { encoding: "utf8" })) : {};
20-
export const importMap = new ImportMap({ rootUrl, map })
19+
export const map = existsSync(nodeImportMapPath)
20+
? JSON.parse(readFileSync(nodeImportMapPath, { encoding: "utf8" }))
21+
: {};
22+
export const importMap = new ImportMap({ rootUrl, map });

src/loader.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { cacheMap, nodeImportMapPath } from "src/config";
2-
import { isNodeOrFileProtocol, resolveNodeModuleCachePath, resolveModulePath, resolveParsedModulePath } from 'src/utils';
2+
import {
3+
isNodeOrFileProtocol,
4+
resolveNodeModuleCachePath,
5+
resolveModulePath,
6+
resolveParsedModulePath,
7+
} from "src/utils";
38
import { Context, NextResolve } from "src/types";
49

510
/**

src/utils.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { existsSync, mkdirSync } from "node:fs";
22
import { dirname, join } from "node:path";
33
import { parseUrlPkg } from "@jspm/generator";
44
import { parseNodeModuleCachePath } from "src/parser";
5-
import { cache, importMap } from 'src/config';
5+
import { cache, importMap } from "src/config";
66
import { IS_DEBUGGING } from "src/constants";
77
import { logger } from "src/logger";
88

@@ -32,13 +32,13 @@ export const isNodeOrFileProtocol = (modulePath: string) => {
3232
const isNode = protocol === "node:";
3333
const isFile = protocol === "file:";
3434
return isNode || isFile;
35-
}
35+
};
3636

3737
export const resolveModulePath = (specifier: string, cacheMapPath: string) => {
3838
const modulePath = importMap.resolve(specifier, cacheMapPath);
3939
log.debug("resolveModulePath:", { modulePath });
4040
return modulePath;
41-
}
41+
};
4242

4343
export const resolveNodeModuleCachePath = async (modulePath: string) => {
4444
try {
@@ -51,9 +51,9 @@ export const resolveNodeModuleCachePath = async (modulePath: string) => {
5151
return nodeModuleCachePath;
5252
} catch (err) {
5353
log.error("resolveNodeModuleCachePath:", err);
54-
return
54+
return;
5555
}
56-
}
56+
};
5757

5858
export const resolveParsedModulePath = async (modulePath: string, nodeModuleCachePath: string) => {
5959
try {
@@ -62,6 +62,6 @@ export const resolveParsedModulePath = async (modulePath: string, nodeModuleCach
6262
return parsedNodeModuleCachePath;
6363
} catch (err) {
6464
log.error("resolveParsedModulePath:", err);
65-
return
65+
return;
6666
}
67-
}
67+
};

0 commit comments

Comments
 (0)