-
-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): overrideTargets inherit the named maker config in the Forg…
…e config (#1549)
- Loading branch information
Showing
5 changed files
with
92 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { expect } from 'chai'; | ||
import * as path from 'path'; | ||
import proxyquire from 'proxyquire'; | ||
|
||
import { MakeOptions } from '../../src/api'; | ||
|
||
describe('make', () => { | ||
let make: (opts: MakeOptions) => Promise<any[]>; | ||
beforeEach(() => { | ||
const electronPath = path.resolve(__dirname, 'node_modules/electron'); | ||
make = proxyquire.noCallThru().load('../../src/api/make', { | ||
'../util/electron-version': { | ||
getElectronModulePath: () => Promise.resolve(electronPath), | ||
getElectronVersion: () => Promise.resolve('1.0.0'), | ||
}, | ||
}).default; | ||
}); | ||
describe('overrideTargets inherits from forge config', () => { | ||
it('passes config properly', async () => { | ||
const results = await make({ | ||
arch: 'x64', | ||
dir: path.resolve(__dirname, '..', 'fixture', 'app-with-custom-maker-config'), | ||
overrideTargets: ['../custom-maker'], | ||
platform: 'linux', | ||
skipPackage: true, | ||
}); | ||
|
||
expect(results[0].artifacts).to.deep.equal(['from config']); | ||
}); | ||
}); | ||
}); |
Empty file.
21 changes: 21 additions & 0 deletions
21
packages/api/core/test/fixture/app-with-custom-maker-config/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "test", | ||
"config": { | ||
"forge": { | ||
"makers": [ | ||
{ | ||
"name": "../custom-maker", | ||
"config": { | ||
"artifactPath": "from config" | ||
} | ||
}, | ||
{ | ||
"name": "@electron-forge/non-existent-forge-maker" | ||
} | ||
] | ||
} | ||
}, | ||
"devDependencies": { | ||
"electron": "^1.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ForgePlatform } from '@electron-forge/shared-types'; | ||
import MakerBase from '@electron-forge/maker-base'; | ||
|
||
interface Config { | ||
artifactPath: string; | ||
} | ||
|
||
export default class Maker extends MakerBase<Config> { | ||
name = 'custom-maker'; | ||
|
||
defaultPlatforms = ['linux'] as ForgePlatform[]; | ||
|
||
isSupportedOnCurrentPlatform() { | ||
return true; | ||
} | ||
|
||
async make() { | ||
return Promise.resolve([this.config.artifactPath || 'default']); | ||
} | ||
} |