Skip to content

Commit fd63486

Browse files
fix(generate_docs): Load lib.es6.d.ts from either typescript/lib or typedoc/node_modules/typescript/lib, whichever is found
1 parent a07cb68 commit fd63486

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

generate_docs.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ shelljs.mkdir('-p', DOCGEN_PACKAGE_DIR);
3737
// Register hook to cleanup temp dir
3838
nodeCleanup(() => {
3939
const symlinks = fs.readdirSync(DOCGEN_DIR)
40-
.filter(file => fs.lstatSync(file).isSymbolicLink());
40+
.filter(file => fs.lstatSync(file).isSymbolicLink());
4141
symlinks.forEach(file => fs.unlinkSync(file));
4242
shelljs.rm('-rf', DOCGEN_DIR);
4343
});
@@ -53,7 +53,7 @@ includes.forEach(include => {
5353
const versionline = _exec(`yarn list --pattern ${package}`).stdout
5454
.split(/[\r\n]+/).find(line => line.includes(package));
5555
const match = /.*\@(([^@]*?)(-[a-zA-Z0-9]{8})?$)/.exec(versionline);
56-
const version = match[2];
56+
const version = match[ 2 ];
5757
console.log({ versionline });
5858
console.log({ match });
5959
console.log({ version });
@@ -86,13 +86,25 @@ const cmdLineOpts = Object.keys(typedocOptions)
8686
.join(" ");
8787

8888
process.chdir(DOCGEN_DIR);
89+
90+
const possibleEs6LibPaths = [
91+
'node_modules/typedoc/node_modules/typescript/lib/lib.es6.d.ts',
92+
'node_modules/typescript/lib/lib.es6.d.ts',
93+
].map(libPath => path.join(PACKAGE_DIR, libPath));
94+
95+
const es6LibPath = possibleEs6LibPaths.find(libPath => fs.existsSync(libPath));
96+
97+
if (!es6LibPath) {
98+
throw new Error(`Couldn't find lib.es6.d.ts at ${possibleEs6LibPaths.join(' nor ')}`);
99+
}
100+
89101
const files = []
90102
.concat(TYPEDOC_CONFIG.files || [])
91103
.concat(TS_CONFIG.files.map(x => path.join(DOCGEN_PACKAGE_DIR, x)))
92104
.concat(includes.map(x => path.join(DOCGEN_DIR, kebob(x.package), x.entry)))
93105
.map(x => `${path.normalize(x)}`)
94106
.map(x => `./${path.relative(DOCGEN_DIR, x)}`)
95-
.concat(path.join(PACKAGE_DIR, 'node_modules/typedoc/node_modules/typescript/lib/lib.es6.d.ts'));
107+
.concat(es6LibPath);
96108

97109
// run typedoc command
98110
_exec(`npx typedoc ${cmdLineOpts} ${files.join(' ')}`);

0 commit comments

Comments
 (0)