Skip to content

Commit

Permalink
fix: add appDir in appInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 committed Jan 7, 2019
1 parent f140a18 commit 4399aba
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
7 changes: 5 additions & 2 deletions packages/midway-core/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { MidwayContainer } from './container';
import { MidwayHandlerKey } from './constants';
import { MidwayLoaderOptions } from './interface';
import { MidwayRequestContainer } from './requestContainer';
import * as extend from 'extend2';

const EggLoader = require('egg-core').EggLoader;
const TS_SRC_DIR = 'src';
Expand Down Expand Up @@ -220,8 +221,10 @@ export class MidwayLoader extends EggLoader {
getAppInfo() {
if (!this.appInfo) {
const appInfo = super.getAppInfo();
this.appInfo = Object.assign(appInfo, {
root: appInfo.env === 'local' || appInfo.env === 'unittest' ? this.appDir : appInfo.root
// ROOT == HOME in prod env
this.appInfo = extend(true, appInfo, {
root: appInfo.env === 'local' || appInfo.env === 'unittest' ? this.appDir : appInfo.root,
appDir: this.appDir,
});
}
return this.appInfo;
Expand Down
7 changes: 3 additions & 4 deletions packages/midway-web/config/config.default.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ module.exports = (appInfo) => {
]
};

const appRoot = appInfo.env === 'local' || appInfo.env === 'unittest' ? appInfo.appDir : appInfo.HOME;
exports.alinode = {
logdir: path.join(appRoot, 'logs/alinode'),
logdir: path.join(appInfo.root, 'logs/alinode'),
error_log: [
path.join(appRoot, `logs/${appInfo.pkg.name}/common-error.log`),
path.join(appRoot, 'logs/stderr.log'),
path.join(appInfo.root, `logs/${appInfo.pkg.name}/common-error.log`),
path.join(appInfo.root, 'logs/stderr.log'),
],
packages: [
path.join(appInfo.appDir, 'package.json'),
Expand Down
5 changes: 3 additions & 2 deletions packages/midway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Node.js >= 8.0.0 required.
- ✔︎ Scalable plug-in capabilities and group plug-in Ecology
- ✔︎ Good application layering and decoupling capability
- ✔︎ A good development experience for the future
- ✔︎ Support Egg plugins and koa middleware


## Getting Started
Expand All @@ -43,8 +44,8 @@ $ open http://localhost:7001

## Docs & Community

[Website && Documentations](https://midwayjs.org/midway/)
[All Egg Plugins](https://github.com/search?q=topic%3Aegg-plugin&type=Repositories)
- [Website && Documentations](https://midwayjs.org/midway/)
- [All Egg Plugins](https://github.com/search?q=topic%3Aegg-plugin&type=Repositories)

## Examples

Expand Down

0 comments on commit 4399aba

Please sign in to comment.