Skip to content

Commit 2e5a8bc

Browse files
authored
fix(core): allow the forge.config property in package.json to point to a non-js file (#3070)
1 parent d322e72 commit 2e5a8bc

File tree

7 files changed

+41
-4
lines changed

7 files changed

+41
-4
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@
138138
"typedoc-plugin-missing-exports": "^1.0.0",
139139
"typedoc-plugin-rename-defaults": "^0.6.4",
140140
"typescript": "^4.6.3",
141-
"xvfb-maybe": "^0.2.1"
141+
"xvfb-maybe": "^0.2.1",
142+
"yaml-hook": "^1.0.0"
142143
},
143144
"optionalDependencies": {
144145
"@malept/electron-installer-flatpak": "^0.11.2",

packages/api/core/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"mocha": "^9.0.1",
3737
"proxyquire": "^2.1.3",
3838
"sinon": "^13.0.1",
39-
"sinon-chai": "^3.6.0"
39+
"sinon-chai": "^3.6.0",
40+
"yaml-hook": "^1.0.0"
4041
},
4142
"dependencies": {
4243
"@electron-forge/core-utils": "^6.0.3",

packages/api/core/src/util/forge-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export default async (dir: string): Promise<ResolvedForgeConfig> => {
109109
const packageJSON = await readRawPackageJson(dir);
110110
let forgeConfig: ForgeConfig | string | null = packageJSON.config && packageJSON.config.forge ? packageJSON.config.forge : null;
111111

112-
if (!forgeConfig) {
112+
if (!forgeConfig || typeof forgeConfig === 'string') {
113113
for (const extension of ['.js', ...Object.keys(interpret.extensions)]) {
114114
const pathToConfig = path.resolve(dir, `forge.config${extension}`);
115115
if (await fs.pathExists(pathToConfig)) {

packages/api/core/test/fast/forge-config_spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ describe('forge-config', () => {
114114
expect(conf.defaultResolved).to.equal(true);
115115
});
116116

117+
it(`should resolve the yml config from forge.config.yml if it's specified in config.forge`, async () => {
118+
type DefaultResolvedConfig = ResolvedForgeConfig;
119+
const conf = (await findConfig(path.resolve(__dirname, '../fixture/dummy_ts_conf'))) as DefaultResolvedConfig;
120+
expect(conf.buildIdentifier).to.equal('yml');
121+
});
122+
117123
it('should resolve the TS file exports of forge.config.ts if config.forge does not exist and the TS config exists', async () => {
118124
type DefaultResolvedConfig = ResolvedForgeConfig;
119125
const conf = (await findConfig(path.resolve(__dirname, '../fixture/dummy_default_ts_conf'))) as DefaultResolvedConfig;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
buildIdentifier: 'yml'
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "",
3+
"productName": "",
4+
"version": "1.0.0",
5+
"description": "",
6+
"main": "src/index.js",
7+
"scripts": {
8+
"start": "electron-forge start"
9+
},
10+
"keywords": [],
11+
"author": "",
12+
"license": "MIT",
13+
"config": {
14+
"forge": "./forge.config.yml"
15+
},
16+
"devDependencies": {
17+
"@electron-forge/shared-types": "*",
18+
"electron-prebuilt": "9.9.9"
19+
}
20+
}

yarn.lock

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7493,7 +7493,7 @@ js-yaml@4.1.0, js-yaml@^4.1.0:
74937493
dependencies:
74947494
argparse "^2.0.1"
74957495

7496-
js-yaml@^3.10.0, js-yaml@^3.13.1:
7496+
js-yaml@^3.10.0, js-yaml@^3.12.2, js-yaml@^3.13.1:
74977497
version "3.14.1"
74987498
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537"
74997499
integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==
@@ -11555,6 +11555,14 @@ yallist@^4.0.0:
1155511555
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
1155611556
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
1155711557

11558+
yaml-hook@^1.0.0:
11559+
version "1.0.0"
11560+
resolved "https://registry.yarnpkg.com/yaml-hook/-/yaml-hook-1.0.0.tgz#14d682e949a9cf6f041e2af8278a4d349ccb52b7"
11561+
integrity sha512-iqSS5Mk1F3yBtrfx94hWzmEk0Wxs5QoBRvngAe39t0XA2JJ3jhQN6Snwv/shH1VoZr+ntdhf4EDLmW0WUWBjdQ==
11562+
dependencies:
11563+
js-yaml "^3.12.2"
11564+
pirates "^4.0.1"
11565+
1155811566
yaml@^1.10.0, yaml@^1.10.2:
1155911567
version "1.10.2"
1156011568
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b"

0 commit comments

Comments
 (0)