1
1
import { watch } from 'fs'
2
+ import { join } from 'path'
2
3
import { Command } from 'commander'
3
4
4
5
import pkg from '../package.json'
6
+ import type { CommanderOptions } from './definitions'
5
7
import { build , dependencies } from './utils'
6
8
7
9
const program = new Command ( )
@@ -14,19 +16,21 @@ program
14
16
. option ( '-w --watch' , 'watch' , false )
15
17
. option ( '--cwd <string>' , 'cwd' , process . cwd ( ) )
16
18
. option ( '-a --external-all' , 'externals' , false )
17
- . option ( '-e --external <numbers...>' , 'externals' , [ ] )
18
- . action ( async ( paths : string [ ] , options ) => {
19
+ . option ( '-s --schema' , 'schema' , false )
20
+ . option ( '-sd --schema-dir' , 'schema directory' , join ( process . cwd ( ) , 'schemas' ) )
21
+ . option ( '-e --external <packages...>' , 'externals' , [ ] )
22
+ . action ( async ( paths : string [ ] , options : CommanderOptions ) => {
19
23
const externals = [
20
24
...( options . externalAll ? await dependencies ( options . cwd ) : [ ] ) ,
21
25
...( options . external || [ ] ) ,
22
26
]
23
27
24
- await build ( paths , options . cwd , externals )
28
+ await build ( paths , options , externals )
25
29
26
30
if ( options . watch ) {
27
31
watch ( options . cwd , { recursive : true } , async ( event , filename ) => {
28
32
if ( typeof filename === 'string' && ! filename . includes ( 'dist' ) ) {
29
- await build ( paths , options . cwd , externals )
33
+ await build ( paths , options , externals )
30
34
}
31
35
} )
32
36
}
0 commit comments