Skip to content

Commit

Permalink
fix: append file extension for loading by file-info
Browse files Browse the repository at this point in the history
  • Loading branch information
tada5hi committed Feb 14, 2023
1 parent ffe8107 commit 122e3f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/loader/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function load(input: LocatorInfo | string) : Promise<any> {
return manager.execute(input);
}

return manager.execute(buildLoaderFilePath(input));
return manager.execute(buildLoaderFilePath(input, true));
}

export function loadSync(input: LocatorInfo | string) : any {
Expand All @@ -38,5 +38,5 @@ export function loadSync(input: LocatorInfo | string) : any {
return manager.executeSync(input);
}

return manager.executeSync(buildLoaderFilePath(input));
return manager.executeSync(buildLoaderFilePath(input, true));
}
6 changes: 5 additions & 1 deletion src/loader/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ import { LoaderFilterFn, ScriptFileExportItem } from './built-in';

export function buildLoaderFilePath(input: LocatorInfo | string, withExtension?: boolean) {
let info: LocatorInfo;

if (typeof input === 'string') {
info = pathToLocatorInfo(input);
} else {
info = input;
}

if (withExtension) {
if (
withExtension &&
info.extension
) {
return path.join(info.path, info.name) + info.extension;
}

Expand Down

0 comments on commit 122e3f9

Please sign in to comment.