From 0865cf4952d3d68f125a2b4739fd871b14c53561 Mon Sep 17 00:00:00 2001 From: roymondchen Date: Tue, 29 Aug 2023 16:53:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(cli):=20packages=E8=AE=BE=E7=BD=AEnpm?= =?UTF-8?q?=E5=8C=85=E5=88=9D=E5=A7=8B=E5=8C=96=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/cli/src/utils/resolveAppPackages.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/utils/resolveAppPackages.ts b/packages/cli/src/utils/resolveAppPackages.ts index 215365a00..c18f0e665 100644 --- a/packages/cli/src/utils/resolveAppPackages.ts +++ b/packages/cli/src/utils/resolveAppPackages.ts @@ -44,10 +44,10 @@ const npmInstall = function (dependencies: Record, cwd: string, }[client]; const packages = Object.entries(dependencies) - .map(([name, version]) => `${name}@${version}`) + .map(([name, version]) => (version ? `${name}@${version}` : name)) .join(' '); - const command = `${client} ${install} ${packages}${registry ? `--registry ${registry}` : ''}`; + const command = `${client} ${install} ${packages}${registry ? ` --registry ${registry}` : ''}`; execInfo(cwd); execInfo(command); @@ -395,6 +395,14 @@ const splitNameVersion = function (str: string) { if (typeof str !== 'string') { return {}; } + + if (fs.existsSync(str)) { + return { + name: str, + version: '', + }; + } + const packStr = String.prototype.trim.call(str); const ret = packStr.match(/((^|@).+)@(.+)/); let name = packStr; @@ -426,7 +434,7 @@ const setPackages = (packages: ModuleMainFilePath, app: App, packagePath: string if (!moduleName) throw Error('packages中包含非法配置'); - if (fs.lstatSync(moduleName).isDirectory()) { + if (isDirectory(moduleName)) { if (!fs.existsSync(path.join(moduleName, './package.json'))) { ['index.js', 'index.ts'].forEach((index) => { const indexFile = path.join(moduleName!, `./${index}`);