Skip to content

Commit 4676f51

Browse files
committed
fix: export getLoader
1 parent a7dff88 commit 4676f51

File tree

6 files changed

+26
-19
lines changed

6 files changed

+26
-19
lines changed

__snapshots__/index.test.ts.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
exports['test/index.test.ts export all should keep checking 1'] = [
2+
"EggType",
3+
"ImportResolveError",
4+
"default",
5+
"detectType",
6+
"findEggCore",
7+
"getConfig",
8+
"getExtensions",
9+
"getFrameworkOrEggPath",
10+
"getFrameworkPath",
11+
"getLoadUnits",
12+
"getLoader",
13+
"getPlugins",
14+
"importModule",
15+
"importResolve",
16+
"isESM",
17+
"isSupportTypeScript"
18+
]

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"npminstall": "7",
4545
"rimraf": "6",
4646
"runscript": "2",
47+
"snap-shot-it": "^7.9.10",
4748
"tshy": "3",
4849
"tshy-after": "1",
4950
"typescript": "5"

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { getFrameworkOrEggPath } from './deprecated.js';
66

77
// support import { getFrameworkPath } from '@eggjs/utils'
88
export { getFrameworkPath } from './framework.js';
9-
export { getPlugins, getConfig, getLoadUnits } from './plugin.js';
9+
export { getPlugins, getConfig, getLoadUnits, getLoader, findEggCore } from './plugin.js';
1010
export { getFrameworkOrEggPath } from './deprecated.js';
1111
export * from './import.js';
1212
export * from './error/index.js';

src/plugin.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ interface IEggLoaderOptions {
9292

9393
type EggLoaderImplClass<T = IEggLoader> = new(options: IEggLoaderOptions) => T;
9494

95-
async function getLoader(options: LoaderOptions) {
95+
export async function getLoader(options: LoaderOptions) {
9696
assert(options.framework, 'framework is required');
9797
assert(await exists(options.framework), `${options.framework} should exist`);
9898
if (!(options.baseDir && await exists(options.baseDir))) {
@@ -119,7 +119,7 @@ async function getLoader(options: LoaderOptions) {
119119
});
120120
}
121121

122-
async function findEggCore(options: LoaderOptions): Promise<{ EggCore?: object; EggLoader: EggLoaderImplClass }> {
122+
export async function findEggCore(options: LoaderOptions): Promise<{ EggCore?: object; EggLoader: EggLoaderImplClass }> {
123123
const baseDirRealpath = await realpath(options.baseDir);
124124
const frameworkRealpath = await realpath(options.framework);
125125
const paths = [ frameworkRealpath, baseDirRealpath ];

test/import.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { strict as assert } from 'node:assert';
22
import coffee from 'coffee';
3+
34
import { importResolve, importModule, ImportResolveError } from '../src/index.js';
45
import { getFilepath } from './helper.js';
56

test/index.test.ts

+3-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { strict as assert } from 'node:assert';
2+
import snapshot from 'snap-shot-it';
3+
24
import { detectType, EggType } from '../src/index.js';
35
import * as all from '../src/index.js';
46
import { getFilepath } from './helper.js';
@@ -32,22 +34,7 @@ describe('test/index.test.ts', () => {
3234

3335
describe('export all', () => {
3436
it('should keep checking', () => {
35-
assert.deepEqual(Object.keys(all), [
36-
'EggType',
37-
'ImportResolveError',
38-
'default',
39-
'detectType',
40-
'getConfig',
41-
'getExtensions',
42-
'getFrameworkOrEggPath',
43-
'getFrameworkPath',
44-
'getLoadUnits',
45-
'getPlugins',
46-
'importModule',
47-
'importResolve',
48-
'isESM',
49-
'isSupportTypeScript',
50-
]);
37+
snapshot(Object.keys(all));
5138
});
5239
});
5340
});

0 commit comments

Comments
 (0)