Skip to content

Commit

Permalink
fix: escape file names for make step (#2752)
Browse files Browse the repository at this point in the history
* fix

* fix

* test lol

* remove unused fixture file

* make test gooder
  • Loading branch information
erickzhao authored Jun 16, 2022
1 parent 6bc4b1e commit beb9305
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"express": "^4.17.1",
"express-ws": "^5.0.2",
"fast-glob": "^3.2.7",
"filenamify": "^4.1.0",
"find-up": "^5.0.0",
"form-data": "^4.0.0",
"fs-extra": "^10.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/api/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"electron-packager": "^15.4.0",
"electron-rebuild": "^3.2.6",
"fast-glob": "^3.2.7",
"filenamify": "^4.1.0",
"find-up": "^5.0.0",
"fs-extra": "^10.0.0",
"lodash": "^4.17.20",
Expand Down
3 changes: 2 additions & 1 deletion packages/api/core/src/api/make.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { IForgeResolvableMaker, ForgeConfig, ForgeArch, ForgePlatform, ForgeMake
import MakerBase from '@electron-forge/maker-base';
import fs from 'fs-extra';
import path from 'path';
import filenamify from 'filenamify';

import getForgeConfig from '../util/forge-config';
import { runHook, runMutatingHook } from '../util/hook';
Expand Down Expand Up @@ -179,7 +180,7 @@ export default async ({
info(interactive, `Making for the following targets: ${chalk.cyan(`${targets.map((_t, i) => makers[i].name).join(', ')}`)}`);

const packageJSON = await readMutatedPackageJson(dir, forgeConfig);
const appName = forgeConfig.packagerConfig.name || packageJSON.productName || packageJSON.name;
const appName = filenamify(forgeConfig.packagerConfig.name || packageJSON.productName || packageJSON.name, { replacement: '-' });
const outputs: ForgeMakeResult[] = [];

await runHook(forgeConfig, 'preMake');
Expand Down
16 changes: 16 additions & 0 deletions packages/api/core/test/fast/make_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ import make from '../../src/api/make';
describe('make', () => {
const fixtureDir = path.resolve(__dirname, '..', 'fixture');

it('works with scoped package names', async () => {
const stubbedMake: (opts: MakeOptions) => Promise<ForgeMakeResult[]> = proxyquire.noCallThru().load('../../src/api/make', {
'../util/read-package-json': {
readMutatedPackageJson: () => Promise.resolve(require('../fixture/app-with-scoped-name/package.json')),
},
}).default;
await stubbedMake({
arch: 'x64',
dir: path.join(fixtureDir, 'app-with-scoped-name'),
overrideTargets: ['@electron-forge/maker-zip'],
platform: 'linux',
skipPackage: true,
});
after(() => proxyquire.callThru());
});

describe('overrideTargets inherits from forge config', () => {
let stubbedMake: (opts: MakeOptions) => Promise<ForgeMakeResult[]>;

Expand Down
Empty file.
Binary file not shown.
28 changes: 28 additions & 0 deletions packages/api/core/test/fixture/app-with-scoped-name/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@scope/package",
"productName": "",
"version": "1.0.0",
"description": "",
"main": "src/index.js",
"scripts": {
"start": "electron-forge start"
},
"keywords": [],
"author": "",
"license": "MIT",
"config": {
"forge": {
"makers": [
{
"name": "@electron-forge/maker-zip",
"platforms": [
"linux"
]
}
]
}
},
"devDependencies": {
"electron": "1000.100.10"
}
}

0 comments on commit beb9305

Please sign in to comment.