mirror of
https://github.com/jiahaog/Nativefier
synced 2024-06-29 08:00:47 +02:00
Rename 'pngToIcns to convertToIcns'
This commit is contained in:
parent
ca44ee28aa
commit
34a5a52a28
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
### USAGE
|
### USAGE
|
||||||
|
|
||||||
# ./pngToIcns <input png> <outp icns>
|
# ./convertToIcns <input png> <outp icns>
|
||||||
# Example
|
# Example
|
||||||
# ./pngToIcns.sh ~/sample.png ~/Desktop/converted.icns
|
# ./convertToIcns ~/sample.png ~/Desktop/converted.icns
|
||||||
|
|
||||||
# exit the shell script on error immediately
|
# exit the shell script on error immediately
|
||||||
set -e
|
set -e
|
|
@ -1,6 +1,6 @@
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import helpers from './../helpers/helpers';
|
import helpers from './../helpers/helpers';
|
||||||
import pngToIcns from './../helpers/pngToIcns';
|
import convertToIcns from './../helpers/convertToIcns';
|
||||||
import singleIco from './../helpers/singleIco';
|
import singleIco from './../helpers/singleIco';
|
||||||
const isOSX = helpers.isOSX;
|
const isOSX = helpers.isOSX;
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ function iconBuild(options, callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pngToIcns(options.icon, (error, icnsPath) => {
|
convertToIcns(options.icon, (error, icnsPath) => {
|
||||||
options.icon = icnsPath;
|
options.icon = icnsPath;
|
||||||
if (error) {
|
if (error) {
|
||||||
console.warn('Skipping icon conversion from `.png` to `.icns`: ', error);
|
console.warn('Skipping icon conversion from `.png` to `.icns`: ', error);
|
||||||
|
|
|
@ -5,7 +5,7 @@ import helpers from './helpers';
|
||||||
const isOSX = helpers.isOSX;
|
const isOSX = helpers.isOSX;
|
||||||
tmp.setGracefulCleanup();
|
tmp.setGracefulCleanup();
|
||||||
|
|
||||||
const PNG_TO_ICNS_BIN_PATH = path.join(__dirname, '../..', 'bin/pngToIcns');
|
const PNG_TO_ICNS_BIN_PATH = path.join(__dirname, '../..', 'bin/convertToIcns');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @callback pngToIcnsCallback
|
* @callback pngToIcnsCallback
|
||||||
|
@ -19,7 +19,7 @@ const PNG_TO_ICNS_BIN_PATH = path.join(__dirname, '../..', 'bin/pngToIcns');
|
||||||
* @param {string} icnsDest
|
* @param {string} icnsDest
|
||||||
* @param {pngToIcnsCallback} callback
|
* @param {pngToIcnsCallback} callback
|
||||||
*/
|
*/
|
||||||
function pngToIcns(pngSrc, icnsDest, callback) {
|
function convertToIcns(pngSrc, icnsDest, callback) {
|
||||||
if (!isOSX()) {
|
if (!isOSX()) {
|
||||||
callback('OSX is required to convert .png to .icns icon', pngSrc);
|
callback('OSX is required to convert .png to .icns icon', pngSrc);
|
||||||
return;
|
return;
|
||||||
|
@ -48,10 +48,10 @@ function pngToIcns(pngSrc, icnsDest, callback) {
|
||||||
* @param {string} pngSrc
|
* @param {string} pngSrc
|
||||||
* @param {pngToIcnsCallback} callback
|
* @param {pngToIcnsCallback} callback
|
||||||
*/
|
*/
|
||||||
function pngToIcnsTmp(pngSrc, callback) {
|
function convertToIcnsTmp(pngSrc, callback) {
|
||||||
const tempIconDirObj = tmp.dirSync({unsafeCleanup: true});
|
const tempIconDirObj = tmp.dirSync({unsafeCleanup: true});
|
||||||
const tempIconDirPath = tempIconDirObj.name;
|
const tempIconDirPath = tempIconDirObj.name;
|
||||||
pngToIcns(pngSrc, `${tempIconDirPath}/icon.icns`, callback);
|
convertToIcns(pngSrc, `${tempIconDirPath}/icon.icns`, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default pngToIcnsTmp;
|
export default convertToIcnsTmp;
|
|
@ -5,14 +5,14 @@ import chai from 'chai';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import pngToIcns from './../../lib/helpers/pngToIcns';
|
import convertToIcns from './../../lib/helpers/convertToIcns';
|
||||||
|
|
||||||
let assert = chai.assert;
|
let assert = chai.assert;
|
||||||
|
|
||||||
// Prerequisite for test: to use OSX with sips, iconutil and imagemagick convert
|
// Prerequisite for test: to use OSX with sips, iconutil and imagemagick convert
|
||||||
|
|
||||||
function testConvertPng(pngName, done) {
|
function testConvertPng(pngName, done) {
|
||||||
pngToIcns(path.join(__dirname, '../../', 'test-resources', pngName), (error, icnsPath) => {
|
convertToIcns(path.join(__dirname, '../../', 'test-resources', pngName), (error, icnsPath) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
done(error);
|
done(error);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user