Skip to content

Commit c48d7a5

Browse files
authored
fix: helper app bundle names (#29)
1 parent e250091 commit c48d7a5

4 files changed

Lines changed: 35 additions & 20 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vscode/gulp-electron",
3-
"version": "1.38.1",
3+
"version": "1.38.2",
44
"description": "gulp plugin for packaging Electron into VS Code",
55
"main": "src/index.js",
66
"scripts": {

src/darwin.js

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,9 @@ function patchHelperInfoPlist(opts) {
226226
var input = es.through();
227227
var output = input.pipe(
228228
es.map(function (f, cb) {
229-
if (
230-
!/Contents\/Frameworks\/Electron\ Helper( \w+)?\.app\/Contents\/Info.plist$/i.test(
231-
f.relative
232-
)
233-
) {
229+
const match = /Contents\/Frameworks\/Electron\ Helper( \(\w+\))?\.app\/Contents\/Info.plist$/i.exec(
230+
f.relative);
231+
if (!match) {
234232
return cb(null, f);
235233
}
236234

@@ -246,24 +244,14 @@ function patchHelperInfoPlist(opts) {
246244

247245
f.contents.on("end", function () {
248246
var infoPlist = plist.parse(contents.toString("utf8"));
249-
var match = /\.helper\.([^.]+)$/.exec(
250-
infoPlist["CFBundleIdentifier"] || ""
251-
);
252-
var suffix = match ? match[1] : "";
247+
var suffix = match[1] ?? "";
253248

254249
if (opts.darwinBundleIdentifier) {
255250
infoPlist["CFBundleIdentifier"] =
256251
opts.darwinBundleIdentifier + ".helper";
257-
258-
if (suffix) {
259-
infoPlist["CFBundleIdentifier"] += "." + suffix;
260-
}
261252
}
262253

263-
infoPlist["CFBundleName"] = opts.productName + " Helper";
264-
if (suffix) {
265-
infoPlist["CFBundleName"] += " " + suffix;
266-
}
254+
infoPlist["CFBundleName"] = `${opts.productName} Helper${suffix}`;
267255

268256
if (infoPlist["CFBundleDisplayName"]) {
269257
infoPlist["CFBundleDisplayName"] = infoPlist["CFBundleName"];

test/package.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,33 @@ describe("electron", function () {
115115
assert.equal(infoPlist["CFBundleName"], "FakeTemplateApp")
116116
assert.equal(infoPlist["CFBundleDisplayName"], "FakeTemplateApp")
117117

118+
// Added helper Info.plist validation
119+
var helperBasePath = path.join(
120+
"FakeTemplateApp.app",
121+
"Contents",
122+
"Frameworks"
123+
);
124+
var helperApps = [
125+
"FakeTemplateApp Helper.app",
126+
"FakeTemplateApp Helper (GPU).app",
127+
"FakeTemplateApp Helper (Renderer).app",
128+
"FakeTemplateApp Helper (Plugin).app"
129+
];
130+
helperApps.forEach(function (appName) {
131+
var helperPlistPath = path.join(helperBasePath, appName, "Contents", "Info.plist");
132+
if (files[helperPlistPath]) {
133+
var helperPlist = plist.parse(files[helperPlistPath].contents.toString("utf8"));
134+
var expectedName = appName.replace(/\.app$/, "");
135+
assert.equal(helperPlist["CFBundleName"], expectedName, "CFBundleName should be updated");
136+
if (helperPlist["CFBundleDisplayName"]) {
137+
assert.equal(helperPlist["CFBundleDisplayName"], expectedName, "CFBundleDisplayName should be updated");
138+
}
139+
if (helperPlist["CFBundleExecutable"]) {
140+
assert.equal(helperPlist["CFBundleExecutable"], expectedName, "CFBundleExecutable should be renamed");
141+
}
142+
}
143+
});
144+
118145
cb();
119146
});
120147
});

0 commit comments

Comments
 (0)