Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: escape file names for make step #2752

Merged
merged 5 commits into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,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 @@ -178,7 +179,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
18 changes: 18 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,24 @@ 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/dummy_app_scoped_name/package.json')),
},
}).default;
await expect(
stubbedMake({
arch: 'x64',
dir: path.join(fixtureDir, 'maker-scoped'),
overrideTargets: ['@electron-forge/maker-zip'],
platform: 'linux',
skipPackage: true,
})
).to.eventually.be.rejectedWith(/@scope-package-linux-x64/);
after(() => proxyquire.callThru());
});

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

Expand Down
Empty file.
24 changes: 24 additions & 0 deletions packages/api/core/test/fixture/dummy_app_scoped_name/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@scope/package",
"productName": "",
"version": "1.0.0",
"description": "",
"main": "src/index.js",
"scripts": {
"start": "electron-forge start"
},
"keywords": [],
"author": "",
"license": "MIT",
"config": {
"forge": {
"packagerConfig": {
"baz": {}
},
"s3": {}
}
},
"devDependencies": {
"electron": "1000.100.10"
}
}