Skip to content
Permalink
Browse files

refactor(generic): add wrappers for console.info and console.warn

  • Loading branch information
malept committed Feb 1, 2017
1 parent c8a15f4 commit f223df85e86c05d82376ce6d090d60cb1f0e1137
Showing with 24 additions and 10 deletions.
  1. +4 −5 src/api/import.js
  2. +2 −1 src/api/install.js
  3. +5 −4 src/api/make.js
  4. +13 −0 src/util/messages.js
@@ -8,6 +8,7 @@ import initGit from '../init/init-git';
import { deps, devDeps } from '../init/init-npm';

import asyncOra from '../util/ora-handler';
import { info, warn } from '../util/messages';
import installDepList from '../util/install-dependencies';
import readPackageJSON from '../util/read-package-json';
import confirmIfInteractive from '../util/confirm-if-interactive';
@@ -55,7 +56,7 @@ export default async (providedOptions = {}) => {

let packageJSON = await readPackageJSON(dir);
if (packageJSON.config && packageJSON.config.forge) {
if (interactive) console.warn('It looks like this project is already configured for "electron-forge"'.green);
warn(interactive, 'It looks like this project is already configured for "electron-forge"'.green);
const shouldContinue = await confirmIfInteractive(interactive, 'Are you sure you want to continue?');

if (!shouldContinue) {
@@ -206,11 +207,10 @@ export default async (providedOptions = {}) => {
}), null, 2));
});

if (interactive) console.info('NOTE: You might be able to remove your `.compilerc` file completely if you are only using the `es2015` and `react` presets'.yellow); // eslint-disable-line max-len
info(interactive, 'NOTE: You might be able to remove your `.compilerc` file completely if you are only using the `es2016` and `react` presets'.yellow);
}

if (interactive) {
console.info(`
info(interactive, `
We have ATTEMPTED to convert your app to be in a format that electron-forge understands.
Nothing much will have changed but we added the ${'"electron-prebuilt-compile"'.cyan} dependency. This is \
@@ -223,5 +223,4 @@ Also please note if you are using \`preload\` scripts you need to follow the ste
at https://github.com/electron-userland/electron-forge/wiki/Using-%27preload%27-scripts
Thanks for using ${'"electron-forge"'.green}!!!`);
}
};
@@ -10,6 +10,7 @@ import pify from 'pify';
import semver from 'semver';

import asyncOra from '../util/ora-handler';
import { info } from '../util/messages';

import darwinDMGInstaller from '../installers/darwin/dmg';
import darwinZipInstaller from '../installers/darwin/zip';
@@ -100,7 +101,7 @@ export default async (providedOptions = {}) => {
}
});

if (interactive) console.info(`Found latest release${prerelease ? ' (including prereleases)' : ''}: ${latestRelease.tag_name.cyan}`);
info(interactive, `Found latest release${prerelease ? ' (including prereleases)' : ''}: ${latestRelease.tag_name.cyan}`);

let targetAsset = possibleAssets[0];
if (possibleAssets.length > 1) {
@@ -5,6 +5,7 @@ import path from 'path';
import asyncOra from '../util/ora-handler';
import electronHostArch from '../util/electron-host-arch';
import getForgeConfig from '../util/forge-config';
import { info, warn } from '../util/messages';
import readPackageJSON from '../util/read-package-json';
import requireSearch from '../util/require-search';
import resolveDir from '../util/resolve-dir';
@@ -53,15 +54,15 @@ export default async (providedOptions = {}) => {
}

if (!skipPackage) {
if (interactive) console.info('We need to package your application before we can make it'.green);
info(interactive, 'We need to package your application before we can make it'.green);
await packager({
dir,
interactive,
arch,
platform,
});
} else if (interactive) {
console.warn('WARNING: Skipping the packaging step, this could result in an out of date build'.red);
} else {
warn(interactive, 'WARNING: Skipping the packaging step, this could result in an out of date build'.red);
}

const declaredArch = arch;
@@ -72,7 +73,7 @@ export default async (providedOptions = {}) => {
targets = overrideTargets;
}

if (interactive) console.info('Making for the following targets:', `${targets.join(', ')}`.cyan);
info(interactive, 'Making for the following targets:', `${targets.join(', ')}`.cyan);

let targetArchs = [declaredArch];
if (declaredArch === 'all') {
@@ -0,0 +1,13 @@
function info(interactive, message) {
if (interactive) {
console.info(message);
}
}

function warn(interactive, message) {
if (interactive) {
console.warn(message);
}
}

export { info, warn };

0 comments on commit f223df8

Please sign in to comment.
You can’t perform that action at this time.