File tree 3 files changed +41
-2
lines changed
3 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -5,12 +5,15 @@ import { ResolvedForgeConfig } from '@electron-forge/shared-types';
5
5
const BASE_OUT_DIR = 'out' ;
6
6
7
7
export default ( baseDir : string , forgeConfig : ResolvedForgeConfig ) : string => {
8
+ const baseOutDir = forgeConfig . outDir || BASE_OUT_DIR ;
9
+
8
10
if ( forgeConfig . buildIdentifier ) {
9
11
let identifier = forgeConfig . buildIdentifier ;
10
12
if ( typeof identifier === 'function' ) {
11
13
identifier = identifier ( ) ;
12
14
}
13
- if ( identifier ) return path . resolve ( baseDir , BASE_OUT_DIR , identifier ) ;
15
+ if ( identifier ) return path . resolve ( baseDir , baseOutDir , identifier ) ;
14
16
}
15
- return path . resolve ( baseDir , BASE_OUT_DIR ) ;
17
+
18
+ return path . resolve ( baseDir , baseOutDir ) ;
16
19
} ;
Original file line number Diff line number Diff line change @@ -30,3 +30,35 @@ describe('out-dir', () => {
30
30
} ) ;
31
31
} ) ;
32
32
} ) ;
33
+
34
+ describe ( 'out-dir-dist' , ( ) => {
35
+ const DIR = __dirname ;
36
+
37
+ describe ( 'getCurrentOutDir' , ( ) => {
38
+ it ( 'resolves to the dist directory when dist is declared' , ( ) => {
39
+ expect (
40
+ getCurrentOutDir ( DIR , {
41
+ outDir : 'dist' ,
42
+ } as ResolvedForgeConfig )
43
+ ) . to . equal ( `${ DIR } ${ path . sep } dist` ) ;
44
+ } ) ;
45
+
46
+ it ( 'resolves to the provided identifier' , ( ) => {
47
+ expect (
48
+ getCurrentOutDir ( DIR , {
49
+ buildIdentifier : 'bar' ,
50
+ outDir : 'dist' ,
51
+ } as ResolvedForgeConfig )
52
+ ) . to . equal ( `${ DIR } ${ path . sep } dist${ path . sep } bar` ) ;
53
+ } ) ;
54
+
55
+ it ( 'resolves to the return value of provided identifier getter' , ( ) => {
56
+ expect (
57
+ getCurrentOutDir ( DIR , {
58
+ buildIdentifier : ( ) => 'thing' ,
59
+ outDir : 'dist' ,
60
+ } as ResolvedForgeConfig )
61
+ ) . to . equal ( `${ DIR } ${ path . sep } dist${ path . sep } thing` ) ;
62
+ } ) ;
63
+ } ) ;
64
+ } ) ;
Original file line number Diff line number Diff line change @@ -85,6 +85,10 @@ export interface ResolvedForgeConfig {
85
85
* If a function is provided, it must synchronously return the buildIdentifier
86
86
*/
87
87
buildIdentifier ?: string | ( ( ) => string ) ;
88
+ /**
89
+ * Output directory. Default is './out'.
90
+ */
91
+ outDir ?: string ;
88
92
hooks ?: ForgeHookMap ;
89
93
/**
90
94
* @internal
You can’t perform that action at this time.
0 commit comments