mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
fix(cli): packages设置npm包初始化报错
This commit is contained in:
parent
131ec6fff3
commit
0865cf4952
@ -44,10 +44,10 @@ const npmInstall = function (dependencies: Record<string, string>, cwd: string,
|
|||||||
}[client];
|
}[client];
|
||||||
|
|
||||||
const packages = Object.entries(dependencies)
|
const packages = Object.entries(dependencies)
|
||||||
.map(([name, version]) => `${name}@${version}`)
|
.map(([name, version]) => (version ? `${name}@${version}` : name))
|
||||||
.join(' ');
|
.join(' ');
|
||||||
|
|
||||||
const command = `${client} ${install} ${packages}${registry ? `--registry ${registry}` : ''}`;
|
const command = `${client} ${install} ${packages}${registry ? ` --registry ${registry}` : ''}`;
|
||||||
|
|
||||||
execInfo(cwd);
|
execInfo(cwd);
|
||||||
execInfo(command);
|
execInfo(command);
|
||||||
@ -395,6 +395,14 @@ const splitNameVersion = function (str: string) {
|
|||||||
if (typeof str !== 'string') {
|
if (typeof str !== 'string') {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fs.existsSync(str)) {
|
||||||
|
return {
|
||||||
|
name: str,
|
||||||
|
version: '',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const packStr = String.prototype.trim.call(str);
|
const packStr = String.prototype.trim.call(str);
|
||||||
const ret = packStr.match(/((^|@).+)@(.+)/);
|
const ret = packStr.match(/((^|@).+)@(.+)/);
|
||||||
let name = packStr;
|
let name = packStr;
|
||||||
@ -426,7 +434,7 @@ const setPackages = (packages: ModuleMainFilePath, app: App, packagePath: string
|
|||||||
|
|
||||||
if (!moduleName) throw Error('packages中包含非法配置');
|
if (!moduleName) throw Error('packages中包含非法配置');
|
||||||
|
|
||||||
if (fs.lstatSync(moduleName).isDirectory()) {
|
if (isDirectory(moduleName)) {
|
||||||
if (!fs.existsSync(path.join(moduleName, './package.json'))) {
|
if (!fs.existsSync(path.join(moduleName, './package.json'))) {
|
||||||
['index.js', 'index.ts'].forEach((index) => {
|
['index.js', 'index.ts'].forEach((index) => {
|
||||||
const indexFile = path.join(moduleName!, `./${index}`);
|
const indexFile = path.join(moduleName!, `./${index}`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user