diff --git a/.circleci/config.yml b/.circleci/config.yml
index e278e7b..7b9ad64 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -17,10 +17,6 @@ jobs:
path: "src/label/test-images"
- store_artifacts:
path: "src/resize/test-images"
- test-node6:
- <<: *test-common
- docker:
- - image: dwmkerr/node:6-imagemagick
test-node8:
<<: *test-common
docker:
@@ -38,11 +34,6 @@ workflows:
version: 2
build:
jobs:
- - test-node6:
- # All branches, all tags.
- filters:
- tags:
- only: /.*/
- test-node8:
# All branches, all tags.
filters:
diff --git a/.eslintrc.yml b/.eslintrc.yml
index 5650ec8..de322d5 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -1,4 +1,6 @@
-extends: airbnb-base
+extends:
+ - airbnb-base
+ - plugin:node/recommended
env:
node: true
mocha: true
@@ -10,3 +12,4 @@ rules:
# tests, so relax the requirement to have single return statements
arrow-body-style: 0
import/no-extraneous-dependencies: [error, { devDependencies: ['**/*.specs.js'] }]
+ no-process-exit: 0
diff --git a/README.md b/README.md
index e05758a..76270fd 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
[![npm version](https://badge.fury.io/js/app-icon.svg)](https://badge.fury.io/js/app-icon) [![CircleCI](https://circleci.com/gh/dwmkerr/app-icon.svg?style=shield)](https://circleci.com/gh/dwmkerr/app-icon) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/3e334rknhjbpx555?svg=true)](https://ci.appveyor.com/project/dwmkerr/app-icon) [![codecov](https://codecov.io/gh/dwmkerr/app-icon/branch/master/graph/badge.svg)](https://codecov.io/gh/dwmkerr/app-icon) [![dependencies Status](https://david-dm.org/dwmkerr/app-icon/status.svg)](https://david-dm.org/dwmkerr/app-icon) [![devDependencies Status](https://david-dm.org/dwmkerr/app-icon/dev-status.svg)](https://david-dm.org/dwmkerr/app-icon?type=dev) [![GuardRails badge](https://badges.production.guardrails.io/dwmkerr/app-icon.svg)](https://www.guardrails.io) [![Greenkeeper badge](https://badges.greenkeeper.io/dwmkerr/app-icon.svg)](https://greenkeeper.io/) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
-Icon management for Mobile Apps. Create icons, generate all required sizes, label and annotate. Supports Native, Cordova, React Native, Xamarin and more. Inspired by [cordova-icon](https://github.com/AlexDisler/cordova-icon). Node 6 and onwards supported.
+Icon management for Mobile Apps. Create icons, generate all required sizes, label and annotate. Supports Native, Cordova, React Native, Xamarin and more. Inspired by [cordova-icon](https://github.com/AlexDisler/cordova-icon). Node 8 and onwards supported.
@@ -181,7 +181,7 @@ Note that Adaptive Icons of *all* supported sizes are generated. However, we als
## Developer Guide
-The only dependencies are Node 6 (or above) and Yarn.
+The only dependencies are Node 8 (or above) and Yarn.
Useful commands for development are:
@@ -198,8 +198,8 @@ Currently the linting style is based on [airbnb](https://github.com/airbnb/javas
Install the dependencies (I recommend [Node Version Manager](https://github.com/creationix/nvm)):
```bash
-nvm install 6
-nvm use 6
+nvm install 8
+nvm use 8
git clone git@github.com:dwmkerr/app-icon.git
cd app-icon
npm install && npm test
diff --git a/appveyor.yml b/appveyor.yml
index 29acaee..b46b6d9 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,5 +1,5 @@
environment:
- nodejs_version: "6"
+ nodejs_version: "8"
# Install scripts. (runs after repo cloning)
install:
diff --git a/bin/app-icon.js b/bin/app-icon.js
index 58f1802..8e65574 100755
--- a/bin/app-icon.js
+++ b/bin/app-icon.js
@@ -1,8 +1,6 @@
#!/usr/bin/env node
-// We use Node 6 to keep compatibility high, so need the 'use strict' statement.
-// eslint-disable-next-line
-'use strict';
+/* eslint-disable consistent-return */
const chalk = require('chalk');
const program = require('commander');
@@ -15,14 +13,23 @@ const labelImage = require('../src/label/label-image');
const fileExists = require('../src/utils/file-exists');
// Helper to throw an error if a file doesn't exist.
-const errorIfMissing = (filePath, errorMessage) => {
- return fileExists(filePath).then((exists) => {
- if (!exists) {
- console.error(`${chalk.red('error')}: ${errorMessage}`);
- return process.exit(1);
- }
- return true;
- });
+const errorIfMissing = async (filePath, errorMessage) => {
+ try {
+ await fileExists(filePath);
+ } catch (err) {
+ console.error(`${chalk.red('error')}: ${errorMessage}`);
+ return process.exit(1);
+ }
+};
+
+const imageMagickCheck = async () => {
+ const version = await imagemagickCli.getVersion();
+
+ if (!version) {
+ console.error(' Error: ImageMagick must be installed. Try:');
+ console.error(' brew install imagemagick');
+ return process.exit(1);
+ }
};
// Create the program.
@@ -39,7 +46,7 @@ program
.option('--background-icon [optional]', "The background icon path. Defaults to 'icon.background.png'")
.option('--foreground-icon [optional]', "The foregroud icon path. Defaults to 'icon.foregroud.png'")
.option('--adaptive-icons [optional]', "Additionally, generate Android Adaptive Icon templates. Defaults to 'false'")
- .action((parameters) => {
+ .action(async (parameters) => {
const {
icon,
backgroundIcon,
@@ -48,43 +55,31 @@ program
platforms,
adaptiveIcons,
} = parameters;
- imagemagickCli.getVersion()
- .then((version) => {
- if (!version) {
- console.error(' Error: ImageMagick must be installed. Try:');
- console.error(' brew install imagemagick');
- process.exit(1);
- }
- })
- .then(() => {
- // Check we have the files we need.
- const operations = [];
- operations.push(errorIfMissing(icon, `Source file '${icon}' does not exist. Add the file or specify source icon with the '--icon' parameter.`));
- if (adaptiveIcons) {
- const checkPath = backgroundIcon || 'icon.background.png';
- operations.push(errorIfMissing(checkPath, `Background icon file '${checkPath}' does not exist. Add the file or specify background icon with the '--background-icon' parameter.`));
- }
- if (adaptiveIcons) {
- const checkPath = foregroundIcon || 'icon.foreground.png';
- operations.push(errorIfMissing(checkPath, `Foreground icon file '${checkPath}' does not exist. Add the file or specify foreground icon with the '--foreground-icon' parameter.`));
- }
- return Promise.all(operations);
- })
- .then(() => {
- // Generate some icons.
- return generate({
- sourceIcon: icon,
- backgroundIcon,
- foregroundIcon,
- searchRoot: search,
- platforms,
- adaptiveIcons,
- });
- })
- .catch((generateErr) => {
- console.error(chalk.red(`An error occurred generating the icons: ${generateErr.message}`));
- return process.exit(1);
+
+ await imageMagickCheck();
+
+ await errorIfMissing(icon, `Source file '${icon}' does not exist. Add the file or specify source icon with the '--icon' parameter.`);
+ if (adaptiveIcons) {
+ const checkPath = backgroundIcon || 'icon.background.png';
+ await errorIfMissing(checkPath, `Background icon file '${checkPath}' does not exist. Add the file or specify background icon with the '--background-icon' parameter.`);
+ }
+ if (adaptiveIcons) {
+ const checkPath = foregroundIcon || 'icon.foreground.png';
+ await errorIfMissing(checkPath, `Foreground icon file '${checkPath}' does not exist. Add the file or specify foreground icon with the '--foreground-icon' parameter.`);
+ }
+ try {
+ await generate({
+ sourceIcon: icon,
+ backgroundIcon,
+ foregroundIcon,
+ searchRoot: search,
+ platforms,
+ adaptiveIcons,
});
+ } catch (err) {
+ console.error(chalk.red(`An error occurred generating the icons: ${err.message}`));
+ process.exit(1);
+ }
});
// Define the 'label' command.
@@ -95,7 +90,7 @@ program
.option('-o, --output