2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-12-23 10:38:55 +00:00

Fix the icon parameter for linux and windows

This commit is contained in:
Jia Hao 2016-01-26 14:24:47 +08:00
parent d0cddfde43
commit 6b0d10f9d4
3 changed files with 39 additions and 5 deletions

View File

@ -119,11 +119,16 @@ Specifies if the source code within the nativefied app should be packaged into a
```
-i, --icon <path>
```
##### OSX
On OSX, the icon parameter should be a path to an `.icns` file. [iConvertIcons](https://iconverticons.com/online/) can be used to convert `.pngs`, though it can be quite cumbersome.
The icon parameter should be a path to an `.icns` file. [iConvertIcons](https://iconverticons.com/online/) can be used to convert `.pngs`, though it can be quite cumbersome.
To retrieve the `.icns` file from the downloaded file, extract it first and press File > Get Info. Then select the icon in the top left corner of the info window and press `⌘-C`. Open Preview and press File > New from clipboard and save the `.icns` file. It took me a while to figure out how to do that and question why a `.icns` file was not simply provided in the downloaded archive.
##### Windows & Linux
The icon parameter should be a path to a `.png` file.
#### [badge]
```

View File

@ -58,16 +58,45 @@ function buildApp(options, callback) {
},
(tempDir, options, callback) => {
options.dir = tempDir;
packager(options, callback);
packager(options, (error, appPathArray) => {
callback(error, options, appPathArray);
});
},
(appPathArray, callback) => {
(options, appPathArray, callback) => {
// somehow appPathArray is a 1 element array
if (appPathArray.length === 0) {
// directory already exists, --overwrite is not set
// exit here
callback();
return;
}
if (appPathArray.length > 1) {
console.warn('Warning: Packaged app path contains more than one element:', appPathArray);
}
const appPath = appPathArray[0];
callback(null, appPath);
if (!options.icon) {
callback(null, appPath);
return;
}
console.log(options);
if (options.platform === 'darwin') {
// todo mac icon copy
console.log('darwin exit');
callback(null, appPath);
return;
}
// windows & linux
const destIconPath = path.join(appPath, 'resources/app');
copy(options.icon, path.join(destIconPath, 'icon.png'), error => {
callback(error, appPath);
});
}
], callback);
}

View File

@ -22,7 +22,7 @@ if (require.main === module) {
.option('-o, --overwrite', 'if output directory for a platform already exists, replaces it rather than skipping it, defaults to false')
.option('-c, --conceal', 'packages the source code within your app into an archive, defaults to false, see http://electron.atom.io/docs/v0.36.0/tutorial/application-packaging/')
.option('--counter', 'if the target app should use a persistant counter badge in the dock (OSX only), defaults to false')
.option('-i, --icon <value>', 'the icon file to use as the icon for the app (should be a .icns file on OSX)')
.option('-i, --icon <value>', 'the icon file to use as the icon for the app (should be a .icns file on OSX, .png for Windows and Linux)')
.option('--width <value>', 'set window width, defaults to 1280px', parseInt)
.option('--height <value>', 'set window height, defaults to 800px', parseInt)
.option('-m, --show-menu-bar', 'set menu bar visible, defaults to false')