@@ -43,7 +43,7 @@ function validatePluginToml(pluginName: string, pluginPath: string): ValidationE
4343 errors . push ( {
4444 plugin : pluginName ,
4545 field : 'plugin.toml' ,
46- message : `解析失败: ${ e instanceof Error ? e . message : String ( e ) } ` ,
46+ message : `解析失败: ${ e instanceof Error ? e . message : String ( e ) } ` ,
4747 } )
4848 return errors
4949 }
@@ -99,11 +99,24 @@ function main() {
9999 process . exit ( 0 )
100100 }
101101
102- const pluginDirs = fs . readdirSync ( pluginsDir , { withFileTypes : true } )
102+ // 支持命令行参数指定要验证的插件
103+ const args = process . argv . slice ( 2 )
104+ let pluginDirs : string [ ]
105+
106+ if ( args . length > 0 ) {
107+ // 验证指定的插件
108+ pluginDirs = args . filter ( name => {
109+ const pluginPath = path . join ( pluginsDir , name )
110+ return fs . existsSync ( pluginPath )
111+ } )
112+ } else {
113+ // 验证所有插件
114+ pluginDirs = fs . readdirSync ( pluginsDir , { withFileTypes : true } )
103115 . filter ( entry => entry . isDirectory ( ) && ! entry . name . startsWith ( '.' ) )
104116 . map ( entry => entry . name )
117+ }
105118
106- console . log ( `验证 ${ pluginDirs . length } 个插件...\n` )
119+ console . log ( `验证 ${ pluginDirs . length } 个插件...\n` )
107120
108121 for ( const pluginName of pluginDirs ) {
109122 const pluginPath = path . join ( pluginsDir , pluginName )
@@ -113,21 +126,21 @@ function main() {
113126
114127 if ( allErrors . length === 0 ) {
115128 console . log ( '所有插件验证通过' )
116- console . log ( `\n允许的 tags: ${ VALID_TAGS . join ( ', ' ) } ` )
117- console . log ( `允许的 database: ${ VALID_DATABASES . join ( ', ' ) } ` )
129+ console . log ( `\n允许的 tags: ${ VALID_TAGS . join ( ', ' ) } ` )
130+ console . log ( `允许的 database: ${ VALID_DATABASES . join ( ', ' ) } ` )
118131 process . exit ( 0 )
119132 }
120133
121134 console . error ( '验证失败:\n' )
122135 for ( const error of allErrors ) {
123- console . error ( `[${ error . plugin } ] ${ error . field } : ${ error . message } ` )
136+ console . error ( `[${ error . plugin } ] ${ error . field } : ${ error . message } ` )
124137 if ( error . invalidValues ) {
125- console . error ( ` 无效值: ${ error . invalidValues . join ( ', ' ) } ` )
138+ console . error ( ` 无效值: ${ error . invalidValues . join ( ', ' ) } ` )
126139 }
127140 }
128141
129- console . error ( `\n允许的 tags: ${ VALID_TAGS . join ( ', ' ) } ` )
130- console . error ( `允许的 database: ${ VALID_DATABASES . join ( ', ' ) } ` )
142+ console . error ( `\n允许的 tags: ${ VALID_TAGS . join ( ', ' ) } ` )
143+ console . error ( `允许的 database: ${ VALID_DATABASES . join ( ', ' ) } ` )
131144 process . exit ( 1 )
132145}
133146
0 commit comments