@@ -3,16 +3,13 @@ import { runCommand } from './utils.js';
3
3
import fs from 'fs' ;
4
4
import path from 'path' ;
5
5
import fg from 'fast-glob' ;
6
- import process from "process" ;
7
- import { defineConfig } from 'tsup'
8
6
9
-
10
- async function doBuildComponents ( ) {
7
+ async function doBuildComponents ( ) {
11
8
// set log prefix
12
9
setGlobalPrefix ( '[ikun-ui]: ' ) ;
13
10
const rootDir = path . resolve ( 'components' ) ;
14
- const targetFile = [ '**/package.json' ] ;
15
- const buildCommand = 'pnpm run build'
11
+ const targetFile = [ '**/package.json' ] ;
12
+ const buildCommand = 'pnpm run build' ;
16
13
17
14
function getPkgPath ( includeCompile , dir ) {
18
15
return fg . sync ( includeCompile , {
@@ -22,25 +19,25 @@ import { defineConfig } from 'tsup'
22
19
}
23
20
const pkgList = getPkgPath ( targetFile , rootDir ) ;
24
21
for ( let i = 0 ; i < pkgList . length ; i ++ ) {
25
- const packageJsonPath = `${ rootDir . replaceAll ( '\\' , '/' ) } /${ pkgList [ i ] } ` ;
22
+ const packageJsonPath = `${ rootDir . replaceAll ( '\\' , '/' ) } /${ pkgList [ i ] } ` ;
26
23
try {
27
24
const packageJsonData = fs . readFileSync ( packageJsonPath , 'utf8' ) ;
28
25
const packageJson = JSON . parse ( packageJsonData ) ;
29
26
if ( packageJson . scripts && packageJson . scripts . build ) {
30
- try {
27
+ try {
31
28
log ( 'info' , `build ${ packageJson . name } ` ) ;
32
- await runCommand ( buildCommand , packageJsonPath . replaceAll ( 'package.json' , '' ) ) ;
29
+ await runCommand ( buildCommand , packageJsonPath . replaceAll ( 'package.json' , '' ) ) ;
33
30
log ( 'success' , `build ${ packageJson . name } complete` ) ;
34
- } catch ( error ) {
35
- log ( 'error' , `build error at ${ packageJson . name } ` , error ) ;
36
- log ( 'error' , error ) ;
37
- }
31
+ } catch ( error ) {
32
+ log ( 'error' , `build error at ${ packageJson . name } ` , error ) ;
33
+ log ( 'error' , error ) ;
34
+ }
38
35
}
39
36
} catch ( error ) {
40
37
log ( 'error' , `Error reading or parsing package.json at ${ packageJsonPath } ` ) ;
41
- log ( 'error' , error ) ;
38
+ log ( 'error' , error ) ;
42
39
}
43
40
}
44
41
}
45
42
46
- doBuildComponents ( )
43
+ doBuildComponents ( ) ;
0 commit comments