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