Skip to content

Commit 1f478ba

Browse files
committed
Update discover-submodules.js
1 parent e5096da commit 1f478ba

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

scripts/discover-submodules.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
const { execSync } = require('child_process');
22

3-
// log current directory
4-
// console.log('Current directory:', execSync('pwd').toString().trim());
53
let json = [];
64

75
try {
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(/https:\/\/github.com\/([^\/]+)\/.*/, '$1');
1818
const repo = url.replace(/https:\/\/github.com\/[^\/]+\/([^\/]+).*/, '$1').replace(/\.git$/, '');
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

0 commit comments

Comments
 (0)