From c09f85c4f7ee55e0dd4e5f5122351d352bfc6e71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=80=AA=E4=BF=8A=E6=9D=B0?= Date: Tue, 29 Mar 2022 15:36:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=80=82=E9=85=8Dworkspaces=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E8=B7=91=E5=8D=95=E6=B5=8B=E5=92=8Ce2e?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/epay-sparta-service/lib/index.js | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/packages/epay-sparta-service/lib/index.js b/packages/epay-sparta-service/lib/index.js index 8b88b65..a71bc31 100644 --- a/packages/epay-sparta-service/lib/index.js +++ b/packages/epay-sparta-service/lib/index.js @@ -35,10 +35,10 @@ class Service { process.env.NODE_ENV = 'test' process.env.BABEL_ENV = 'test' defaultWebpackConfig = require('./webpack/webpack.config.test').getConfig(this) - SubService = this.resolveNpmPackage('@epay-sparta/cli-plugin-unit-test') + SubService = require('@epay-sparta/cli-plugin-unit-test') break case 'test:e2e': - SubService = this.resolveNpmPackage('@epay-sparta/cli-plugin-e2e-test') + SubService = require('@epay-sparta/cli-plugin-e2e-test') break // If mode is not the one of values unpon, show error tip. default: @@ -56,23 +56,6 @@ class Service { return path.resolve(process.cwd(), dir) } - resolveNpmPackage(packageName) { - const pkgJson = require(this.resolve('package.json')) - const hasTargetPackageInPkgJson = - pkgJson.devDependencies.hasOwnProperty(packageName) || - pkgJson.dependencies.hasOwnProperty(packageName) - if (hasTargetPackageInPkgJson) { - const targetPkgPath = this.resolve(`node_modules/${packageName}`) - const targetPkgJson = this.require(`${targetPkgPath}/package.json`) - return require(path.resolve(targetPkgPath, targetPkgJson.main)) - } - error( - `The npm package '${packageName}' hasn't be installed.\n` + - `You may try: npm install -S ${packageName}.` - ) - process.exit(1) - } - require(path) { return fs.existsSync(path) ? require(path) : {} }