-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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: Add support for multiple extensions to Keygen publisher #6234
Merged
mmaietta
merged 3 commits into
electron-userland:master
from
ezekg:fix/keygen-publisher-version-taken-error
Sep 8, 2021
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion
2
packages/app-builder-lib/src/options/CommonWindowsInstallerConfiguration.ts
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
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,39 @@ | ||
// @ts-ignore | ||
import * as _sanitizeFileName from "sanitize-filename" | ||
import * as path from "path" | ||
|
||
export function sanitizeFileName(s: string): string { | ||
return _sanitizeFileName(s) | ||
} | ||
|
||
// Get the filetype from a filename. Returns a string of one or more file extensions, | ||
// e.g. .zip, .dmg, .tar.gz, .tar.bz2, .exe.blockmap. We'd normally use `path.extname()`, | ||
// but it doesn't support multiple extensions, e.g. Foo-1.0.0.dmg.blockmap should be | ||
// .dmg.blockmap, not .blockmap. | ||
export function getCompleteExtname(filename: string): string { | ||
let extname = path.extname(filename) | ||
|
||
switch (extname) { | ||
// Append leading extension for blockmap filetype | ||
case ".blockmap": { | ||
extname = path.extname(filename.replace(extname, "")) + extname | ||
|
||
break | ||
} | ||
// Append leading extension for known compressed tar formats | ||
case ".bz2": | ||
case ".gz": | ||
case ".lz": | ||
case ".xz": | ||
case ".7z": { | ||
const ext = path.extname(filename.replace(extname, "")) | ||
if (ext === ".tar") { | ||
extname = ext + extname | ||
} | ||
|
||
break | ||
} | ||
} | ||
|
||
return extname | ||
} |
This file was deleted.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
packages/electron-builder-squirrel-windows/src/SquirrelWindowsTarget.ts
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
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,41 @@ | ||
import { getCompleteExtname } from "app-builder-lib/out/util/filename" | ||
|
||
// [inputFilename, expectedExtname] | ||
const tests = [ | ||
["Foo-v1.exe.blockmap", ".exe.blockmap"], | ||
["Foo-1.0.0.dmg.blockmap", ".dmg.blockmap"], | ||
["Foo-v1.0.0.exe.blockmap", ".exe.blockmap"], | ||
["Foo-1.0.0-mac.zip.blockmap", ".zip.blockmap"], | ||
["Foo-1.0.0.exe", ".exe"], | ||
["foo-1.0.0.exe", ".exe"], | ||
["foo.bar-1.0.0.dmg", ".dmg"], | ||
["Foo-2.0.0.rc1.dmg", ".dmg"], | ||
["Foo-1.0.0-mac.dmg", ".dmg"], | ||
["Foo-v1.0.0.zip", ".zip"], | ||
["Foo-1.0.0.tar.gz", ".tar.gz"], | ||
["Foo-1.0.0.tar.7z", ".tar.7z"], | ||
["Foo-1.0.0.7z", ".7z"], | ||
["Foo-1.0.0.test.7z", ".7z"], | ||
["Foo-1.0.0.tar.xz", ".tar.xz"], | ||
["Foo-1.0.0.tar.lz", ".tar.lz"], | ||
["Foo-1.0.0.tar.bz2", ".tar.bz2"], | ||
["Foo.v2.tar.bz2", ".tar.bz2"], | ||
["Foo-v1.0.0.tar.bz2", ".tar.bz2"], | ||
["Application.test.dmg", ".dmg"], | ||
["Program.1.0.0.beta1.exe", ".exe"], | ||
["application.dmg", ".dmg"], | ||
["latest.yml", ".yml"], | ||
[".gitignore", ""], | ||
[".config.yml", ".yml"], | ||
["code.h", ".h"], | ||
] | ||
|
||
describe("getCompleteExtname", () => { | ||
for (const [filename, expected] of tests) { | ||
test(`get complete extname for ${filename}`, () => { | ||
const extname = getCompleteExtname(filename) | ||
|
||
expect(extname).toBe(expected) | ||
}) | ||
} | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth noting that renaming this file may be a breaking change if anybody is relying on
util/sanitizeFileName
. I assume it's meant to be internal, but ya know.