1- import { extractFile } from "asar-electron-builder "
1+ import { extractFile } from "asar"
22import BluebirdPromise from "bluebird-lst"
3- import { Arch , BuildOptions , DIR_TARGET , PackagerOptions , Platform } from "electron-builder"
3+ import { Arch , BuildOptions , DIR_TARGET , Platform } from "electron-builder"
44import { build , normalizeOptions } from "electron-builder/out/builder"
55import { createYargs } from "electron-builder/out/cli/cliOptions"
66import { checkWineVersion } from "electron-builder/out/packager"
@@ -9,7 +9,9 @@ import isCi from "is-ci"
99import * as path from "path"
1010import { ELECTRON_VERSION } from "./helpers/config"
1111import { assertThat } from "./helpers/fileAssert"
12- import { allPlatforms , app , appThrows , appTwoThrows , assertPack , getPossiblePlatforms , modifyPackageJson , packageJson } from "./helpers/packTester"
12+ import { allPlatforms , app , appThrows , appTwo , appTwoThrows , assertPack , getPossiblePlatforms , modifyPackageJson , packageJson } from "./helpers/packTester"
13+
14+ const linuxDirTarget = Platform . LINUX . createTarget ( DIR_TARGET )
1315
1416test ( "cli" , async ( ) => {
1517 const yargs = createYargs ( )
@@ -80,24 +82,22 @@ test.ifNotWindows("custom buildResources and output dirs: mac", createBuildResou
8082test . ifNotCiMac ( "custom buildResources and output dirs: win" , createBuildResourcesTest ( Platform . WINDOWS ) )
8183test . ifNotWindows ( "custom buildResources and output dirs: linux" , createBuildResourcesTest ( Platform . LINUX ) )
8284
83- test ( "build in the app package.json" , appTwoThrows ( allPlatforms ( ) , {
85+ test ( "build in the app package.json" , appTwoThrows ( linuxDirTarget , {
8486 projectDirCreated : it => modifyPackageJson ( it , data => {
8587 data . build = {
8688 "iconUrl" : "bar" ,
8789 }
8890 } , true )
8991} ) )
9092
91- test ( "name in the build" , appThrows ( currentPlatform ( ) , { projectDirCreated : packageJson ( it => it . build = { "name" : "Cool App" } ) } ) )
92-
93- test ( "relative index" , ( ) => assertPack ( "test-app" , allPlatforms ( false ) , {
93+ test ( "relative index" , appTwo ( allPlatforms ( false ) , {
9494 projectDirCreated : projectDir => modifyPackageJson ( projectDir , data => {
9595 data . main = "./index.js"
9696 } , true )
9797} ) )
9898
9999it . ifDevOrLinuxCi ( "electron version from electron-prebuilt dependency" , app ( {
100- targets : Platform . LINUX . createTarget ( DIR_TARGET ) ,
100+ targets : linuxDirTarget ,
101101} , {
102102 projectDirCreated : projectDir => BluebirdPromise . all ( [
103103 outputJson ( path . join ( projectDir , "node_modules" , "electron-prebuilt" , "package.json" ) , {
@@ -111,7 +111,7 @@ it.ifDevOrLinuxCi("electron version from electron-prebuilt dependency", app({
111111} ) )
112112
113113test . ifDevOrLinuxCi ( "electron version from electron dependency" , app ( {
114- targets : Platform . LINUX . createTarget ( DIR_TARGET ) ,
114+ targets : linuxDirTarget ,
115115} , {
116116 projectDirCreated : projectDir => BluebirdPromise . all ( [
117117 outputJson ( path . join ( projectDir , "node_modules" , "electron" , "package.json" ) , {
@@ -125,20 +125,20 @@ test.ifDevOrLinuxCi("electron version from electron dependency", app({
125125} ) )
126126
127127test . ifDevOrLinuxCi ( "electron version from build" , app ( {
128- targets : Platform . LINUX . createTarget ( DIR_TARGET ) ,
128+ targets : linuxDirTarget ,
129129} , {
130130 projectDirCreated : projectDir => modifyPackageJson ( projectDir , data => {
131131 data . devDependencies = { }
132132 data . build . electronVersion = ELECTRON_VERSION
133133 } )
134134} ) )
135135
136- test ( "www as default dir" , ( ) => assertPack ( "test-app" , currentPlatform ( ) , {
136+ test ( "www as default dir" , appTwo ( Platform . current ( ) . createTarget ( DIR_TARGET ) , {
137137 projectDirCreated : projectDir => move ( path . join ( projectDir , "app" ) , path . join ( projectDir , "www" ) )
138138} ) )
139139
140140test ( "afterPack" , ( ) => {
141- const targets = isCi ? Platform . fromString ( process . platform ) . createTarget ( DIR_TARGET ) : getPossiblePlatforms ( DIR_TARGET )
141+ const targets = isCi ? Platform . current ( ) . createTarget ( DIR_TARGET ) : getPossiblePlatforms ( DIR_TARGET )
142142 let called = 0
143143 return assertPack ( "test-app-one" , {
144144 targets : targets ,
@@ -156,7 +156,7 @@ test("afterPack", () => {
156156} )
157157
158158test ( "beforeBuild" , ( ) => {
159- const targets = isCi ? Platform . fromString ( process . platform ) . createTarget ( DIR_TARGET ) : getPossiblePlatforms ( DIR_TARGET )
159+ const targets = isCi ? Platform . current ( ) . createTarget ( DIR_TARGET ) : getPossiblePlatforms ( DIR_TARGET )
160160 let called = 0
161161 return assertPack ( "test-app-one" , {
162162 targets : targets ,
@@ -174,39 +174,31 @@ test("beforeBuild", () => {
174174 } )
175175} )
176176
177- test . ifDevOrLinuxCi ( "smart unpack" , ( ) => {
178- return assertPack ( "test-app-one" , {
179- targets : Platform . LINUX . createTarget ( DIR_TARGET ) ,
180- } , {
181- npmInstallBefore : true ,
182- projectDirCreated : packageJson ( it => {
183- it . dependencies = {
184- "debug" : "^2.2.0" ,
185- "edge-cs" : "^1.0.0"
186- }
187- } ) ,
188- packed : context => {
189- expect ( JSON . parse ( extractFile ( path . join ( context . getResources ( Platform . LINUX ) , "app.asar" ) , "node_modules/debug/package.json" ) . toString ( ) ) ) . toMatchObject ( {
190- name : "debug"
191- } )
192- return BluebirdPromise . resolve ( )
177+ test . ifDevOrLinuxCi ( "smart unpack" , app ( {
178+ targets : linuxDirTarget ,
179+ } , {
180+ npmInstallBefore : true ,
181+ projectDirCreated : packageJson ( it => {
182+ it . dependencies = {
183+ "debug" : "^2.2.0" ,
184+ "edge-cs" : "^1.0.0"
193185 }
194- } )
195- } )
186+ } ) ,
187+ packed : context => {
188+ expect ( JSON . parse ( extractFile ( path . join ( context . getResources ( Platform . LINUX ) , "app.asar" ) , "node_modules/debug/package.json" ) . toString ( ) ) ) . toMatchObject ( {
189+ name : "debug"
190+ } )
191+ return BluebirdPromise . resolve ( )
192+ }
193+ } ) )
196194
197195test ( "wine version" , async ( ) => {
198196 await checkWineVersion ( BluebirdPromise . resolve ( "1.9.23 (Staging)" ) )
199197 await checkWineVersion ( BluebirdPromise . resolve ( "2.0-rc2" ) )
200198} )
201199
202- function currentPlatform ( ) : PackagerOptions {
203- return {
204- targets : Platform . fromString ( process . platform ) . createTarget ( DIR_TARGET ) ,
205- }
206- }
207-
208200test . ifDevOrLinuxCi ( "prepackaged" , app ( {
209- targets : Platform . LINUX . createTarget ( DIR_TARGET ) ,
201+ targets : linuxDirTarget ,
210202} , {
211203 packed : async ( context ) => {
212204 await build ( normalizeOptions ( {
@@ -219,7 +211,7 @@ test.ifDevOrLinuxCi("prepackaged", app({
219211} ) )
220212
221213test . ifDevOrLinuxCi ( "scheme validation" , appThrows ( {
222- targets : Platform . LINUX . createTarget ( DIR_TARGET ) ,
214+ targets : linuxDirTarget ,
223215 config : < any > {
224216 foo : 123 ,
225217 mac : {
@@ -229,7 +221,7 @@ test.ifDevOrLinuxCi("scheme validation", appThrows({
229221} ) )
230222
231223test . ifDevOrLinuxCi ( "scheme validation 2" , appThrows ( {
232- targets : Platform . LINUX . createTarget ( DIR_TARGET ) ,
224+ targets : linuxDirTarget ,
233225 config : < any > {
234226 appId : 123 ,
235227 } ,
0 commit comments