mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
feat(cli): 新增npm install 参数配置
This commit is contained in:
parent
e6909dc052
commit
3cae4fbc1c
@ -50,6 +50,7 @@ export interface NpmConfig {
|
|||||||
autoInstall?: boolean;
|
autoInstall?: boolean;
|
||||||
/** 安装组件后,npm默认会将依赖写入package.json中,将该值设置为true,则不会写入,默认为true */
|
/** 安装组件后,npm默认会将依赖写入package.json中,将该值设置为true,则不会写入,默认为true */
|
||||||
keepPackageJsonClean?: boolean;
|
keepPackageJsonClean?: boolean;
|
||||||
|
installArgs?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModuleMainFilePath {
|
export interface ModuleMainFilePath {
|
||||||
|
@ -38,7 +38,7 @@ const getRelativePath = (str: string, base: string) => (path.isAbsolute(str) ? p
|
|||||||
|
|
||||||
const npmInstall = function (dependencies: Record<string, string>, cwd: string, npmConfig: NpmConfig = {}) {
|
const npmInstall = function (dependencies: Record<string, string>, cwd: string, npmConfig: NpmConfig = {}) {
|
||||||
try {
|
try {
|
||||||
const { client = 'npm', registry } = npmConfig;
|
const { client = 'npm', registry, installArgs = '' } = npmConfig;
|
||||||
const install = {
|
const install = {
|
||||||
npm: 'install',
|
npm: 'install',
|
||||||
yarn: 'add',
|
yarn: 'add',
|
||||||
@ -49,7 +49,9 @@ const npmInstall = function (dependencies: Record<string, string>, cwd: string,
|
|||||||
.map(([name, version]) => (version ? `${name}@${version}` : name))
|
.map(([name, version]) => (version ? `${name}@${version}` : name))
|
||||||
.join(' ');
|
.join(' ');
|
||||||
|
|
||||||
const command = `${client} ${install} ${packages}${registry ? ` --registry ${registry}` : ''}`;
|
const installArgsString = `${installArgs ? ` ${installArgs}` : ''}`;
|
||||||
|
const registryString = `${registry ? ` --registry ${registry}` : ''}`;
|
||||||
|
const command = `${client} ${install}${installArgsString} ${packages}${registryString}`;
|
||||||
|
|
||||||
execInfo(cwd);
|
execInfo(cwd);
|
||||||
execInfo(command);
|
execInfo(command);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user