1
+ import { parseArgs } from '@ionic/cli-framework' ;
1
2
import { mkdirp } from '@ionic/utils-fs' ;
2
3
import * as path from 'path' ;
3
4
@@ -15,22 +16,23 @@ export class Integration extends BaseIntegration {
15
16
async add ( details : IntegrationAddDetails , handlers : IntegrationAddHandlers = { } ) : Promise < void > {
16
17
let name = this . e . project . config . get ( 'name' ) ;
17
18
let packageId = 'io.ionic.starter' ;
19
+ const options : string [ ] = [ ] ;
18
20
19
21
if ( details . enableArgs ) {
20
- if ( details . enableArgs [ 0 ] ) {
21
- name = details . enableArgs [ 0 ] ;
22
- }
22
+ const parsedArgs = parseArgs ( details . enableArgs ) ;
23
23
24
- if ( details . enableArgs [ 1 ] ) {
25
- packageId = details . enableArgs [ 1 ] ;
24
+ name = parsedArgs [ '_' ] [ 0 ] || name ;
25
+ packageId = parsedArgs [ '_' ] [ 1 ] || packageId ;
26
+ if ( parsedArgs [ 'web-dir' ] ) {
27
+ options . push ( '--web-dir' , parsedArgs [ 'web-dir' ] ) ;
26
28
}
27
29
}
28
30
29
31
await this . installCapacitorCore ( ) ;
30
32
await this . installCapacitorCLI ( ) ;
31
33
32
34
await mkdirp ( details . root ) ;
33
- await this . e . shell . run ( 'capacitor' , [ 'init' , name , packageId ] , { cwd : details . root } ) ;
35
+ await this . e . shell . run ( 'capacitor' , [ 'init' , name , packageId , ... options ] , { cwd : details . root } ) ;
34
36
35
37
await super . add ( details , handlers ) ;
36
38
}
0 commit comments