Content-Length: 302855 | pFad | https://github.com/midwayjs/midway/commit/e9f689c07efec3078c77557f29ea9ecdb5659094

87 fix: 2.x fix conflicts (#459) · midwayjs/midway@e9f689c · GitHub
Skip to content

Commit

Permalink
fix: 2.x fix conflicts (#459)
Browse files Browse the repository at this point in the history
* fix dfs circular depth bug

* remove lodash

* add isProvide

* chore: upgrade isProvide logic code

Co-authored-by: kurten <chinkurten@gmail.com>
  • Loading branch information
czy88840616 and kurten authored Apr 7, 2020
1 parent 2b0f44c commit e9f689c
Showing 1 changed file with 38 additions and 27 deletions.
65 changes: 38 additions & 27 deletions packages/midway-core/src/context/midwayContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,21 @@ import {
PIPELINE_IDENTIFIER,
listModule,
CONFIGURATION_KEY,
isProvide
isProvide,
} from '@midwayjs/decorator';
import * as is from 'is-type-of';
import { join } from 'path';
import { ContainerConfiguration } from './configuration';
import { FUNCTION_INJECT_KEY, MidwayHandlerKey } from '../common/constants';
import { IConfigService, IEnvironmentService, IMidwayContainer, IApplicationContext, MAIN_MODULE_KEY, IContainerConfiguration, ILifeCycle } from '../interface';
import {
IConfigService,
IEnvironmentService,
IMidwayContainer,
IApplicationContext,
MAIN_MODULE_KEY,
IContainerConfiguration,
ILifeCycle,
} from '../interface';
import { MidwayConfigService } from '../service/configService';
import { MidwayEnvironmentService } from '../service/environmentService';
import { Container } from './container';
Expand Down Expand Up @@ -56,7 +64,7 @@ export class MidwayContainer extends Container implements IMidwayContainer {

constructor(
baseDir: string = process.cwd(),
parent: IApplicationContext = undefined,
parent: IApplicationContext = undefined
) {
super(baseDir, parent);
}
Expand Down Expand Up @@ -128,7 +136,7 @@ export class MidwayContainer extends Container implements IMidwayContainer {
followSymbolicLinks: false,
cwd: dir,
ignore: DEFAULT_IGNORE_PATTERN.concat(opts.ignore || []),
suppressErrors: true
suppressErrors: true,
}
);

Expand Down Expand Up @@ -156,14 +164,13 @@ export class MidwayContainer extends Container implements IMidwayContainer {
}

protected bindModule(module, namespace = '', filePath?: string) {
if (is.class(module) && isProvide(module)) {
const providerId = getProviderId(module);
if (is.class(module)) {
const providerId = isProvide(module) ? getProviderId(module) : null;
if (providerId) {
this.bind(
generateProvideId(providerId, namespace),
module,
{ namespace, srcPath: filePath }
);
this.bind(generateProvideId(providerId, namespace), module, {
namespace,
srcPath: filePath,
});
} else {
// no provide or js class must be skip
}
Expand All @@ -178,16 +185,12 @@ export class MidwayContainer extends Container implements IMidwayContainer {
if (!info.scope) {
info.scope = ScopeEnum.Request;
}
this.bind(
generateProvideId(info.id, namespace),
module,
{
scope: info.scope,
isAutowire: info.isAutowire,
namespace,
srcPath: filePath
}
);
this.bind(generateProvideId(info.id, namespace), module, {
scope: info.scope,
isAutowire: info.isAutowire,
namespace,
srcPath: filePath,
});
}
}
}
Expand Down Expand Up @@ -409,20 +412,28 @@ export class MidwayContainer extends Container implements IMidwayContainer {
this.bindModule(pipelineFactory);
}

private loadConfiguration(opts: any, containerConfiguration: IContainerConfiguration) {
private loadConfiguration(
opts: any,
containerConfiguration: IContainerConfiguration
) {
const subDirs = containerConfiguration.getImportDirectory();
if (subDirs && subDirs.length > 0) {
debug('load configuration dir => %j, namespace => %s.',
subDirs, containerConfiguration.namespace);
debug(
'load configuration dir => %j, namespace => %s.',
subDirs,
containerConfiguration.namespace
);
this.loadDirectory({
...opts,
loadDir: subDirs,
namespace: containerConfiguration.namespace
namespace: containerConfiguration.namespace,
});
}

this.registerImportObjects(containerConfiguration.getImportObjects(),
containerConfiguration.namespace);
this.registerImportObjects(
containerConfiguration.getImportObjects(),
containerConfiguration.namespace
);
}

private async loadAndReadyLifeCycles() {
Expand Down

0 comments on commit e9f689c

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/midwayjs/midway/commit/e9f689c07efec3078c77557f29ea9ecdb5659094

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy