File tree Expand file tree Collapse file tree 4 files changed +28
-8
lines changed Expand file tree Collapse file tree 4 files changed +28
-8
lines changed Original file line number Diff line number Diff line change 793
793
794
794
## v0.20.31 (2021-03-14)
795
795
796
+ ### Features
797
+
798
+ - Improved warning message if TypeDoc is loaded multiple times.
799
+
796
800
### Bug Fixes
797
801
798
802
- readonly tuples were recognized as arrays, closes #1534
Original file line number Diff line number Diff line change 1
1
//@ts -check
2
2
3
- const { remove, copy } = require ( "../dist/lib/utils/fs" ) ;
3
+ const fs = require ( "fs/promises" ) ;
4
+ const { copy } = require ( "../dist/lib/utils/fs" ) ;
4
5
const { join } = require ( "path" ) ;
5
6
6
7
const expectedDir = join ( __dirname , "../dist/tmp/.reg/expected" ) ;
7
8
const outputDir = join ( __dirname , "../dist/tmp/__screenshots__" ) ;
8
9
9
- remove ( expectedDir )
10
+ fs . rmdir ( expectedDir , { recursive : true } )
10
11
. then ( ( ) => copy ( outputDir , expectedDir ) )
11
12
. catch ( ( err ) => {
12
13
console . error ( err ) ;
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ import {
31
31
getWatchEntryPoints ,
32
32
} from "./utils/entry-point" ;
33
33
import { nicePath } from "./utils/paths" ;
34
- import { hasBeenLoadedMultipleTimes } from "./utils/general" ;
34
+ import { getLoadedPaths , hasBeenLoadedMultipleTimes } from "./utils/general" ;
35
35
import { validateExports } from "./validation/exports" ;
36
36
import { validateDocumentation } from "./validation/documentation" ;
37
37
import { validateLinks } from "./validation/links" ;
@@ -152,7 +152,9 @@ export class Application extends ChildableComponent<
152
152
153
153
if ( hasBeenLoadedMultipleTimes ( ) ) {
154
154
this . logger . warn (
155
- `TypeDoc has been loaded multiple times. This is commonly caused by plugins which have their own installation of TypeDoc. This will likely break things.`
155
+ `TypeDoc has been loaded multiple times. This is commonly caused by plugins which have their own installation of TypeDoc. The loaded paths are:\n\t${ getLoadedPaths ( ) . join (
156
+ "\n\t"
157
+ ) } `
156
158
) ;
157
159
}
158
160
}
Original file line number Diff line number Diff line change
1
+ import { dirname } from "path" ;
1
2
import * as Util from "util" ;
2
3
3
4
/**
@@ -59,11 +60,23 @@ export function assertNever(x: never): never {
59
60
* multiple times, then parts of it will not work as expected.
60
61
*/
61
62
const loadSymbol = Symbol . for ( "typedoc_loads" ) ;
62
- const getLoads = ( ) => globalThis [ loadSymbol as never ] || 0 ;
63
+ const pathSymbol = Symbol . for ( "typedoc_paths" ) ;
63
64
64
- // @ts -expect-error there's no way to add symbols to globalThis, sadly.
65
- globalThis [ loadSymbol ] = getLoads ( ) + 1 ;
65
+ interface TypeDocGlobals {
66
+ [ loadSymbol ] ?: number ;
67
+ [ pathSymbol ] ?: string [ ] ;
68
+ }
69
+ const g = globalThis as TypeDocGlobals ;
70
+
71
+ g [ loadSymbol ] = ( g [ loadSymbol ] || 0 ) + 1 ;
72
+ g [ pathSymbol ] ||= [ ] ;
73
+ // transform /abs/path/to/typedoc/dist/lib/utils/general -> /abs/path/to/typedoc
74
+ g [ pathSymbol ] . push ( dirname ( dirname ( dirname ( __dirname ) ) ) ) ;
66
75
67
76
export function hasBeenLoadedMultipleTimes ( ) {
68
- return getLoads ( ) !== 1 ;
77
+ return g [ loadSymbol ] !== 1 ;
78
+ }
79
+
80
+ export function getLoadedPaths ( ) {
81
+ return g [ pathSymbol ] || [ ] ;
69
82
}
You can’t perform that action at this time.
0 commit comments