forked from oliverschwendener/ueli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed windows-system-icon dependency
- Loading branch information
1 parent
286bed6
commit 1717eb6
Showing
5 changed files
with
94 additions
and
47 deletions.
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
59 changes: 59 additions & 0 deletions
59
src/main/plugins/application-search-plugin/windows-app-icon-generator.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { FileHelpers } from "../../../common/helpers/file-helpers"; | ||
import { applicationIconLocation, getApplicationIconFilePath } from "./application-icon-helpers"; | ||
import * as Shell from "node-powershell"; | ||
|
||
interface Icon { | ||
inputFilePath: string; | ||
outputFilePath: string; | ||
outputFormat: string; | ||
} | ||
|
||
export function generateWindowsAppIcons(applicationFilePaths: string[]): Promise<void> { | ||
return new Promise((resolve, reject) => { | ||
if (applicationFilePaths.length === 0) { | ||
resolve(); | ||
} | ||
|
||
FileHelpers.fileExists(applicationIconLocation) | ||
.then((fileExists) => { | ||
if (!fileExists) { | ||
FileHelpers.createFolderSync(applicationIconLocation); | ||
} | ||
|
||
const icons = applicationFilePaths.map((applicationFilePath): Icon => { | ||
return { | ||
inputFilePath: applicationFilePath, | ||
outputFilePath: getApplicationIconFilePath(applicationFilePath), | ||
outputFormat: "Png", | ||
}; | ||
}); | ||
|
||
generateIcons(icons) | ||
.then(() => resolve()) | ||
.catch((err) => reject(err)); | ||
}) | ||
.catch((err) => reject(err)); | ||
}); | ||
} | ||
|
||
function generateIcons(icons: Icon[], followShortcuts?: boolean): Promise<void> { | ||
return new Promise((resolve, reject) => { | ||
const ps = new Shell({ | ||
executionPolicy: "Bypass", | ||
noProfile: true, | ||
}); | ||
|
||
ps.addCommand(`Add-Type -AssemblyName System.Drawing`); | ||
|
||
icons.forEach((icon) => { | ||
ps.addCommand(`$fileExists = Test-Path -Path "${icon.inputFilePath}";`); | ||
ps.addCommand(`if($fileExists) { $icon = [System.Drawing.Icon]::ExtractAssociatedIcon("${icon.inputFilePath}"); }`); | ||
ps.addCommand(`if($fileExists) { $bitmap = $icon.ToBitmap().save("${icon.outputFilePath}", [System.Drawing.Imaging.ImageFormat]::${icon.outputFormat}); }`); | ||
}); | ||
|
||
ps.invoke() | ||
.then(() => resolve()) | ||
.catch((err) => reject(err)) | ||
.finally(() => ps.dispose()); | ||
}); | ||
} |
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 |
---|---|---|
|
@@ -389,6 +389,18 @@ | |
dependencies: | ||
decimal.js "^10.0.0" | ||
|
||
"@types/node-powershell@^3.1.0": | ||
version "3.1.0" | ||
resolved "https://registry.yarnpkg.com/@types/node-powershell/-/node-powershell-3.1.0.tgz#09a8d69b8238154eefec220c9318b3e199fa6d58" | ||
integrity sha1-CajWm4I4FU7v7CIMkxiz4Zn6bVg= | ||
dependencies: | ||
"@types/node" "*" | ||
|
||
"@types/node@*": | ||
version "12.6.9" | ||
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.6.9.tgz#ffeee23afdc19ab16e979338e7b536fdebbbaeaf" | ||
integrity sha512-+YB9FtyxXGyD54p8rXwWaN1EWEyar5L58GlGWgtH2I9rGmLGBQcw63+0jw+ujqVavNuO47S1ByAjm9zdHMnskw== | ||
|
||
"@types/node@^10.12.18": | ||
version "10.14.10" | ||
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.10.tgz#e491484c6060af8d461e12ec81c0da8a3282b8de" | ||
|
@@ -935,7 +947,7 @@ bluebird-lst@^1.0.7, bluebird-lst@^1.0.9: | |
dependencies: | ||
bluebird "^3.5.5" | ||
|
||
bluebird@^3.5.0, bluebird@^3.5.1, bluebird@^3.5.5: | ||
bluebird@^3.5.0, bluebird@^3.5.5: | ||
version "3.5.5" | ||
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.5.tgz#a8d0afd73251effbbd5fe384a77d73003c17a71f" | ||
integrity sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w== | ||
|
@@ -1268,7 +1280,7 @@ caseless@~0.12.0: | |
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" | ||
integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= | ||
|
||
chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.4.1, chalk@^2.4.2: | ||
chalk@^2.0.0, chalk@^2.0.1, chalk@^2.3.0, chalk@^2.4.1, chalk@^2.4.2: | ||
version "2.4.2" | ||
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" | ||
integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== | ||
|
@@ -4196,6 +4208,11 @@ nan@^2.12.1: | |
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c" | ||
integrity sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg== | ||
|
||
nanoid@^2.0.0: | ||
version "2.0.3" | ||
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-2.0.3.tgz#dde999e173bc9d7bd2ee2746b89909ade98e075e" | ||
integrity sha512-NbaoqdhIYmY6FXDRB4eYtDVC9Z9eCbn8TyaiC16LNKtpPv/aqa0tOPD8y6gNE4yUNnaZ7LLhYtXOev/6+cBtfw== | ||
|
||
nanomatch@^1.2.9: | ||
version "1.2.13" | ||
resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" | ||
|
@@ -4287,13 +4304,13 @@ node-notifier@^5.2.1: | |
shellwords "^0.1.1" | ||
which "^1.3.0" | ||
|
||
node-powershell@^3.3.1: | ||
version "3.3.1" | ||
resolved "https://registry.yarnpkg.com/node-powershell/-/node-powershell-3.3.1.tgz#bbf76b29f091ed83eae16ad9e7a180a13f36d113" | ||
integrity sha1-u/drKfCR7YPq4WrZ56GAoT820RM= | ||
node-powershell@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/node-powershell/-/node-powershell-4.0.0.tgz#f3a0b1ec4f5619b501b66005f8a663c8373e8da8" | ||
integrity sha512-WCZMLgwkjW9G/DZsZwyCEAXhMMzShLRUlnYS+EETRqRLSdUMbuO4xiQxIOeAutwQgvj75NvC58CorHFlx0olIA== | ||
dependencies: | ||
bluebird "^3.5.1" | ||
chalk "^2.1.0" | ||
chalk "^2.4.1" | ||
shortid "^2.2.14" | ||
|
||
node-pre-gyp@^0.12.0: | ||
version "0.12.0" | ||
|
@@ -5388,6 +5405,13 @@ shellwords@^0.1.1: | |
resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b" | ||
integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww== | ||
|
||
shortid@^2.2.14: | ||
version "2.2.14" | ||
resolved "https://registry.yarnpkg.com/shortid/-/shortid-2.2.14.tgz#80db6aafcbc3e3a46850b3c88d39e051b84c8d18" | ||
integrity sha512-4UnZgr9gDdA1kaKj/38IiudfC3KHKhDc1zi/HSxd9FQDR0VLwH3/y79tZJLsVYPsJgIjeHjqIWaWVRJUj9qZOQ== | ||
dependencies: | ||
nanoid "^2.0.0" | ||
|
||
signal-exit@^3.0.0, signal-exit@^3.0.2: | ||
version "3.0.2" | ||
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" | ||
|
@@ -6402,13 +6426,6 @@ widest-line@^2.0.0: | |
dependencies: | ||
string-width "^2.1.1" | ||
|
||
[email protected]: | ||
version "0.0.5" | ||
resolved "https://registry.yarnpkg.com/windows-system-icon/-/windows-system-icon-0.0.5.tgz#a1d5a7ca728d9934c48d8ae1006d0b2786737775" | ||
integrity sha512-fHYpfMc/xnPj3WftYPB1eRtUUdG2EqfavM46mun/Wl/28m/NqCozZ7GL/jU/7lOlFfcnM5vKFYYb+YqtmW+Cbg== | ||
dependencies: | ||
node-powershell "^3.3.1" | ||
|
||
winston-transport@^4.3.0: | ||
version "4.3.0" | ||
resolved "https://registry.yarnpkg.com/winston-transport/-/winston-transport-4.3.0.tgz#df68c0c202482c448d9b47313c07304c2d7c2c66" | ||
|