Skip to content

Commit 1f715dd

Browse files
fix(generate_docs): Support 'branch' configuration in docgen.json for included repos
1 parent 03f204b commit 1f715dd

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

generate_docs.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ if (!fs.existsSync(DOCGENCONFIG_PATH)) { throw new Error(`${DOCGENCONFIG_PATH} d
2323

2424
const PACKAGEJSON = JSON.parse(fs.readFileSync(PACKAGEJSON_PATH));
2525
const DOCGENCONFIG = getDocgenConfig();
26-
const TSCONFIG_ORIG = JSON.parse(fs.readFileSync(TSCONFIG_PATH));
27-
const TSCONFIG_COPY = _.cloneDeep(TSCONFIG_ORIG);
26+
const TSCONFIG_ORIG_BINARY = fs.readFileSync(TSCONFIG_PATH);
27+
const TSCONFIG_COPY = JSON.parse(TSCONFIG_ORIG_BINARY.toString());
2828

2929
const cleanupFns = [];
3030

3131
// Merge tsconfig block from docgen.json into tsconfig.json
3232
_.defaultsDeep(TSCONFIG_COPY, DOCGENCONFIG.tsconfig);
3333
fs.writeFileSync(TSCONFIG_PATH, JSON.stringify(TSCONFIG_COPY, null, 2));
34-
cleanupFns.push(() => fs.writeFileSync(TSCONFIG_PATH, JSON.stringify(TSCONFIG_ORIG, null, 2)));
35-
shelljs.cat(TSCONFIG_PATH);
34+
cleanupFns.push(() => fs.writeFileSync(TSCONFIG_PATH, TSCONFIG_ORIG_BINARY));
35+
_exec(`cat ${TSCONFIG_PATH}`);
3636

3737
function getDocgenConfig() {
3838
const config = JSON.parse(fs.readFileSync(DOCGENCONFIG_PATH));
@@ -56,7 +56,7 @@ nodeCleanup(() => {
5656
// Fetch all included packages (i.e., core module)
5757
const includes = DOCGENCONFIG.include || [];
5858
includes.forEach((include) => {
59-
const { pkg, repo } = include;
59+
const { pkg, repo, branch } = include;
6060
const semver = ['peerDependencies', 'dependencies', 'devDependencies']
6161
.map((key) => (PACKAGEJSON[key] || {})[pkg])
6262
.find((x) => !!x);
@@ -68,7 +68,7 @@ includes.forEach((include) => {
6868
cleanupFns.push(() => shelljs.rm('-rf', INSTALLDIR));
6969
}
7070

71-
const version = findSemverPackage(pkg, semver);
71+
const version = branch || findSemverPackage(pkg, semver);
7272
shelljs.pushd(INSTALLDIR)
7373
_exec(`git checkout ${version}`);
7474
shelljs.popd()

0 commit comments

Comments
 (0)