File tree Expand file tree Collapse file tree 3 files changed +31
-1
lines changed
packages/electron-builder/src/util Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 11import Ajv from "ajv"
2+ import { CancellationToken } from "electron-builder-http/out/CancellationToken"
23import { debug } from "electron-builder-util"
34import { log , warn } from "electron-builder-util/out/log"
5+ import { httpExecutor } from "electron-builder-util/out/nodeHttpExecutor"
46import { readFile , readJson } from "fs-extra-p"
57import { safeLoad } from "js-yaml"
68import JSON5 from "json5"
@@ -112,6 +114,20 @@ export async function getElectronVersion(config: Config | null | undefined, proj
112114 const packageJsonPath = path . join ( projectDir , "package.json" )
113115 const electronPrebuiltDep = findFromElectronPrebuilt ( projectMetadata || await readJson ( packageJsonPath ) )
114116 if ( electronPrebuiltDep == null ) {
117+ try {
118+ const releaseInfo = await httpExecutor . request < any > ( {
119+ hostname : "github.com" ,
120+ path : "/electron/electron/releases/latest" ,
121+ headers : {
122+ Accept : "application/json" ,
123+ } ,
124+ } , new CancellationToken ( ) )
125+ return ( releaseInfo . tag_name . startsWith ( "v" ) ) ? releaseInfo . tag_name . substring ( 1 ) : releaseInfo . tag_name
126+ }
127+ catch ( e ) {
128+ warn ( e )
129+ }
130+
115131 throw new Error ( `Cannot find electron dependency to get electron version in the '${ packageJsonPath } '` )
116132 }
117133
Original file line number Diff line number Diff line change @@ -79,6 +79,12 @@ Object {
7979}
8080` ;
8181
82+ exports [` retrieve latest electron version 1` ] = `
83+ Object {
84+ " linux" : Array [],
85+ }
86+ ` ;
87+
8288exports [` scheme validation 1` ] = `
8389"Config is invalid:
8490{
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { move, readFile } from "fs-extra-p"
44import { safeLoad } from "js-yaml"
55import * as path from "path"
66import { assertThat } from "./helpers/fileAssert"
7- import { app , appThrows , assertPack } from "./helpers/packTester"
7+ import { app , appThrows , assertPack , modifyPackageJson } from "./helpers/packTester"
88import { expectUpdateMetadata } from "./helpers/winHelper"
99
1010function createBuildResourcesTest ( platform : Platform ) {
@@ -56,6 +56,14 @@ test.ifAll.ifLinuxOrDevMac("prepackaged", app({
5656 }
5757} ) )
5858
59+ test . ifAll . ifLinuxOrDevMac ( "retrieve latest electron version" , app ( {
60+ targets : linuxDirTarget ,
61+ } , {
62+ projectDirCreated : projectDir => modifyPackageJson ( projectDir , data => {
63+ delete data . build . electronVersion
64+ } ) ,
65+ } ) )
66+
5967test . ifAll . ifDevOrLinuxCi ( "override targets in the config" , app ( {
6068 targets : linuxDirTarget ,
6169} , {
You can’t perform that action at this time.
0 commit comments