Skip to content

Commit cbcf402

Browse files
dead-horsefengmk2
authored andcommitted
feat: support options.serverScope for egg-mock (#143)
1 parent 7b55c68 commit cbcf402

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

lib/egg.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ class EggCore extends KoaApplication {
120120
app: this,
121121
plugins: options.plugins,
122122
logger: this.console,
123+
serverScope: options.serverScope,
123124
});
124125

125126
this[INIT_READY]();

lib/loader/egg_loader.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ class EggLoader {
8484
* @member {String} EggLoader#serverScope
8585
* @see AppInfo#serverScope
8686
*/
87-
this.serverScope = this.getServerScope();
87+
this.serverScope = options.serverScope !== undefined
88+
? options.serverScope
89+
: this.getServerScope();
8890
}
8991

9092
/**

test/egg.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ describe('test/egg.test.js', () => {
3737
assert(app.type === 'application');
3838
});
3939

40+
it('should use options.serverScope', () => {
41+
app = new EggCore({ serverScope: 'scope' });
42+
assert(app.loader.serverScope === 'scope');
43+
});
44+
4045
it('should not set value expect for application and agent', () => {
4146
assert.throws(() => {
4247
new EggCore({

0 commit comments

Comments
 (0)