diff --git a/README.md b/README.md index 09e4f61..5d8a276 100644 --- a/README.md +++ b/README.md @@ -119,11 +119,16 @@ Specifies if the source code within the nativefied app should be packaged into a ``` -i, --icon ``` +##### 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] ``` diff --git a/src/buildApp.js b/src/buildApp.js index 68e878d..2c2d426 100644 --- a/src/buildApp.js +++ b/src/buildApp.js @@ -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); } diff --git a/src/cli.js b/src/cli.js index 2e5dc72..09748d7 100755 --- a/src/cli.js +++ b/src/cli.js @@ -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 ', 'the icon file to use as the icon for the app (should be a .icns file on OSX)') + .option('-i, --icon ', '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 ', 'set window width, defaults to 1280px', parseInt) .option('--height ', 'set window height, defaults to 800px', parseInt) .option('-m, --show-menu-bar', 'set menu bar visible, defaults to false')