Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0b09dc4

Browse files
authoredMar 6, 2023
fix(scanner): support relative path as root (#235)
1 parent 7654e26 commit 0b09dc4

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed
 

‎src/scanner/scan.ts

+5
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ export class Scanner {
8282
}
8383

8484
async scan(root: string): Promise<Record<string, Manifest>> {
85+
if (!path.isAbsolute(root)) {
86+
// make sure the root path is absolute
87+
root = path.resolve(root);
88+
}
89+
8590
const result = {};
8691
const envList = await this.scanEnvList(root);
8792

‎test/scanner.test.ts

+8
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ describe('test/scanner.test.ts', () => {
4747
});
4848
});
4949

50+
it('should scan test dir by relative path', async () => {
51+
const scanner = new Scanner({ needWriteFile: false, extensions: ['.ts', '.js', '.json'] });
52+
const relativeRoot = path.relative(process.cwd(), __dirname);
53+
const scanResults = await scanner.scan(path.join(relativeRoot, './fixtures/app_koa_with_ts'));
54+
expect(scanResults?.default?.items).toBeDefined();
55+
expect(scanResults?.dev?.items).toBeDefined();
56+
});
57+
5058
it('should not scan test dir', async () => {
5159
const scanner = new Scanner({ needWriteFile: false, extensions: ['.ts', '.js', '.json'] });
5260
const scanResults = await scanner.scan(path.resolve(__dirname, './fixtures/app_with_lifecycle'));

0 commit comments

Comments
 (0)
Please sign in to comment.