Skip to content

Commit

Permalink
fix(midway-bin): use resolveModule() instead of findFramework() (#344)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: remove findFramework()
  • Loading branch information
waitingsong authored and czy88840616 committed Oct 11, 2019
1 parent 1809d17 commit 8c24e2e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 25 deletions.
1 change: 0 additions & 1 deletion packages/midway-bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ exports.DebugCommand = require('./lib/cmd/debug');
exports.PkgfilesCommand = require('./lib/cmd/pkgfiles');
exports.CleanCommand = require('./lib/cmd/clean');
exports.DocCommand = require('./lib/cmd/doc');
exports.findFramework = require('./lib/util').findFramework;
exports.resolveModule = require('./lib/util').resolveModule;
22 changes: 0 additions & 22 deletions packages/midway-bin/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,6 @@
const fs = require('fs');
const path = require('path');


/**
* Resolve mono-repo's full path
* @param {string} module - module name
* @return {string} full path or blank
*/
function findFramework(module) {
let framePath = '';
const modPath = resolveModule(module);

if (modPath) {
framePath = path.join(modPath, '../../');
} else {
console.log(`[midway-bin] Not found framework "${module}" and skip.`);
}

return framePath;
}


/**
* Resolve module's full path
* @param {string} moduleName module name
Expand Down Expand Up @@ -63,6 +43,4 @@ function retrieveModulePath(moduleName) {
return moduleDir ? path.join(moduleDir, moduleName) : '';
}


exports.findFramework = findFramework;
exports.resolveModule = resolveModule;
4 changes: 2 additions & 2 deletions packages/midway-mock/src/mock.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as mock from 'egg-mock';
import { findFramework } from 'midway-bin';
import { resolveModule } from 'midway-bin';

import { MidwayApplicationOptions, MidwayMockApplication } from './interface';

Expand All @@ -20,7 +20,7 @@ function mockContainer(options: MidwayApplicationOptions): MockContainer {
return new MockContainer(options);
}

const defaultFramework: string = findFramework('midway') || findFramework('midway-mirror');
const defaultFramework: string = resolveModule('midway') || resolveModule('midway-mirror');

export const mm = Object.assign({}, mock, {
container: mockContainer,
Expand Down

0 comments on commit 8c24e2e

Please sign in to comment.