File tree 3 files changed +33
-5
lines changed
3 files changed +33
-5
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,11 @@ import debug from 'debug';
2
2
import * as path from 'path' ;
3
3
4
4
import { getArtifactFileName , getArtifactRemoteURL , FileNameUse } from './artifact-utils' ;
5
- import { ElectronArtifactDetails , ElectronDownloadRequestOptions } from './types' ;
5
+ import {
6
+ ElectronArtifactDetails ,
7
+ ElectronDownloadRequestOptions ,
8
+ ElectronPlatformArtifactDetailsWithDefaults ,
9
+ } from './types' ;
6
10
import { Cache } from './Cache' ;
7
11
import { getDownloaderForSystem } from './downloader-resolver' ;
8
12
import {
@@ -44,10 +48,18 @@ export function download(
44
48
*
45
49
* @param artifactDetails - The information required to download the artifact
46
50
*/
47
- export async function downloadArtifact ( _artifactDetails : ElectronArtifactDetails ) : Promise < string > {
48
- const artifactDetails : ElectronArtifactDetails = {
49
- ..._artifactDetails ,
50
- } ;
51
+ export async function downloadArtifact (
52
+ _artifactDetails : ElectronPlatformArtifactDetailsWithDefaults ,
53
+ ) : Promise < string > {
54
+ const artifactDetails : ElectronArtifactDetails = _artifactDetails . isGeneric
55
+ ? {
56
+ ..._artifactDetails ,
57
+ }
58
+ : {
59
+ platform : process . platform ,
60
+ arch : getHostArch ( ) ,
61
+ ..._artifactDetails ,
62
+ } ;
51
63
ensureIsTruthyString ( artifactDetails , 'version' ) ;
52
64
artifactDetails . version = normalizeVersion ( artifactDetails . version ) ;
53
65
Original file line number Diff line number Diff line change @@ -91,4 +91,13 @@ export type ElectronArtifactDetails =
91
91
| ElectronPlatformArtifactDetails
92
92
| ElectronGenericArtifactDetails ;
93
93
94
+ export type Omit < T , K > = Pick < T , Exclude < keyof T , K > > ;
95
+
96
+ export type ElectronPlatformArtifactDetailsWithDefaults =
97
+ | ( Omit < ElectronPlatformArtifactDetails , 'platform' | 'arch' > & {
98
+ platform ?: string ;
99
+ arch ?: string ;
100
+ } )
101
+ | ElectronGenericArtifactDetails ;
102
+
94
103
export type DownloadOptions = any ;
Original file line number Diff line number Diff line change @@ -120,6 +120,13 @@ describe('Public API', () => {
120
120
expect ( await fs . readFile ( dtsPath , 'utf8' ) ) . toContain ( 'declare namespace Electron' ) ;
121
121
} ) ;
122
122
123
+ it ( 'should work default platform/arch' , async ( ) => {
124
+ await downloadArtifact ( {
125
+ version : '2.0.3' ,
126
+ artifactName : 'electron' ,
127
+ } ) ;
128
+ } ) ;
129
+
123
130
it ( 'should work for chromedriver' , async ( ) => {
124
131
const driverPath = await downloadArtifact ( {
125
132
cacheRoot,
You can’t perform that action at this time.
0 commit comments