File tree Expand file tree Collapse file tree 1 file changed +11
-12
lines changed
Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Original file line number Diff line number Diff line change 11const { execSync } = require ( 'child_process' ) ;
22
3- // log current directory
4- // console.log('Current directory:', execSync('pwd').toString().trim());
53let json = [ ] ;
64
75try {
8- const submoduleNames = execSync ( 'git submodule foreach --quiet "echo \$name"' ) . toString ( ) . split ( '\n' ) . filter ( Boolean ) ;
9- console . log ( 'submoduleNames:' , submoduleNames )
6+ const submodules = execSync ( 'git submodule' )
7+ . toString ( )
8+ . split ( '\n' )
9+ . filter ( Boolean ) ;
1010
11- const topLevelDir = execSync ( 'git rev-parse --show-toplevel' ) . toString ( ) . trim ( ) ;
12- console . log ( 'topLevelDir:' , topLevelDir )
11+ console . log ( "submodules" , submodules ) ;
12+
13+ submodules . forEach ( ( line ) => {
14+ const [ , , name ] = line . split ( ' ' ) ;
15+ const url = execSync ( `git config --get submodule.${ name } .url` ) . toString ( ) . trim ( ) ;
1316
14- submoduleNames . forEach ( ( name ) => {
15- const url = execSync ( `git config --file ${ topLevelDir } /.gitmodules submodule.${ name } .url` ) . toString ( ) . trim ( ) ;
16-
1717 const owner = url . replace ( / h t t p s : \/ \/ g i t h u b .c o m \/ ( [ ^ \/ ] + ) \/ .* / , '$1' ) ;
1818 const repo = url . replace ( / h t t p s : \/ \/ g i t h u b .c o m \/ [ ^ \/ ] + \/ ( [ ^ \/ ] + ) .* / , '$1' ) . replace ( / \. g i t $ / , '' ) ;
19-
19+
2020 json . push ( { owner : owner , repo : repo } ) ;
2121 } ) ;
22- }
23- catch ( error ) {
22+ } catch ( error ) {
2423 console . error ( 'Error processing submodules:' , error ) ;
2524}
2625
You can’t perform that action at this time.
0 commit comments