Allow using png to build for OSX if OS is OSX

This commit is contained in:
Jia Hao 2016-01-27 10:36:30 +08:00
parent 77b2d93fdd
commit 8eaa3a39e0
3 changed files with 24 additions and 2 deletions

View File

@ -18,7 +18,7 @@
"clean": "gulp clean",
"build": "gulp build",
"watch": "while true ; do gulp watch ; done",
"package-placeholder": "npm run build && node lib/cli.js http://www.bennish.net/web-notifications.html ~/Desktop --overwrite --app-name notification-test && open ~/Desktop/notification-test-darwin-x64/notification-test.app",
"package-placeholder": "npm run build && node lib/cli.js http://www.bennish.net/web-notifications.html ~/Desktop --overwrite --app-name notification-test --icon ./test-resources/iconSampleGrey.png && open ~/Desktop/notification-test-darwin-x64/notification-test.app",
"start-placeholder": "npm run build && electron app",
"release": "gulp release"
},

View File

@ -3,6 +3,8 @@ import path from 'path';
import crypto from 'crypto';
import optionsFactory from './options';
import pngToIcns from './getIcon';
import helpers from './helpers';
import packager from 'electron-packager';
import tmp from 'tmp';
import ncp from 'ncp';
@ -12,6 +14,7 @@ import _ from 'lodash';
import packageJson from './../package.json';
const copy = ncp.ncp;
const isOSX = helpers.isOSX;
/**
* @callback buildAppCallback
@ -56,6 +59,17 @@ function buildApp(options, callback) {
callback(error, tempDirPath, options);
});
},
(tempDir, options, callback) => {
if (options.platform !== 'darwin' || !isOSX()) {
callback(null, tempDir, options);
return;
}
pngToIcns(options.icon, (error, icnsPath) => {
options.icon = icnsPath;
callback(error, tempDir, options);
});
},
(tempDir, options, callback) => {
options.dir = tempDir;
packager(options, (error, appPathArray) => {
@ -84,7 +98,6 @@ function buildApp(options, callback) {
}
if (options.platform === 'darwin') {
// todo mac icon copy
callback(null, appPath);
return;
}

9
src/helpers.js Normal file
View File

@ -0,0 +1,9 @@
import os from 'os';
function isOSX() {
return os.platform() === 'darwin';
}
export default {
isOSX: isOSX
};