diff --git a/src/api/import.js b/src/api/import.js index 6ec61e5ddb..ccdb504f52 100644 --- a/src/api/import.js +++ b/src/api/import.js @@ -39,22 +39,21 @@ export default async (providedOptions = {}) => { d(`Attempting to import project in: ${dir}`); if (!await fs.exists(dir) || !await fs.exists(path.resolve(dir, 'package.json'))) { - console.error(`We couldn't find a project in: ${dir}`.red); - process.exit(1); + throw `We couldn't find a project in: ${dir}`; } // eslint-disable-next-line max-len const confirm = await confirmIfInteractive(interactive, `WARNING: We will now attempt to import: "${dir}". This will involve modifying some files, are you sure you want to continue?`); if (!confirm) { - process.exit(1); + process.exit(0); } await initGit(dir); let packageJSON = await readPackageJSON(dir); if (packageJSON.config && packageJSON.config.forge) { - console.warn('It looks like this project is already configured for "electron-forge"'.green); + if (interactive) console.warn('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) { @@ -205,10 +204,11 @@ export default async (providedOptions = {}) => { }), null, 2)); }); - console.info('NOTE: You might be able to remove your `.compilerc` file completely if you are only using the `es2015` and `react` presets'.yellow); + 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 } - console.info(` + if (interactive) { + console.info(` 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 \ @@ -221,4 +221,5 @@ 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}!!!`); + } }; diff --git a/src/api/install.js b/src/api/install.js index 72a9afb824..9a1f6c77dc 100644 --- a/src/api/install.js +++ b/src/api/install.js @@ -100,7 +100,7 @@ export default async (providedOptions = {}) => { } }); - console.info(`Found latest release${prerelease ? ' (including prereleases)' : ''}: ${latestRelease.tag_name.cyan}`); + if (interactive) console.info(`Found latest release${prerelease ? ' (including prereleases)' : ''}: ${latestRelease.tag_name.cyan}`); let targetAsset = possibleAssets[0]; if (possibleAssets.length > 1) { diff --git a/src/api/make.js b/src/api/make.js index 0bc41a3d5d..cc58b137a6 100644 --- a/src/api/make.js +++ b/src/api/make.js @@ -49,19 +49,18 @@ export default async (providedOptions = {}) => { }); if (platform && platform !== process.platform && !(process.platform === 'darwin' && platform === 'mas')) { - console.error('You can not "make" for a platform other than your systems platform'.red); - process.exit(1); + throw 'You can not "make" for a platform other than your systems platform'; } if (!skipPackage) { - console.info('We need to package your application before we can make it'.green); + if (interactive) console.info('We need to package your application before we can make it'.green); await packager({ dir, interactive, arch, platform, }); - } else { + } else if (interactive) { console.warn('WARNING: Skipping the packaging step, this could result in an out of date build'.red); } @@ -73,7 +72,7 @@ export default async (providedOptions = {}) => { targets = overrideTargets; } - console.info('Making for the following targets:', `${targets.join(', ')}`.cyan); + if (interactive) console.info('Making for the following targets:', `${targets.join(', ')}`.cyan); let targetArchs = [declaredArch]; if (declaredArch === 'all') { diff --git a/src/publishers/github.js b/src/publishers/github.js index 2388918e3c..fd021762b2 100644 --- a/src/publishers/github.js +++ b/src/publishers/github.js @@ -6,8 +6,7 @@ import GitHub from '../util/github'; export default async (artifacts, packageJSON, forgeConfig, authToken, tag) => { if (!(forgeConfig.github_repository && typeof forgeConfig.github_repository === 'object' && forgeConfig.github_repository.owner && forgeConfig.github_repository.name)) { - console.error('In order to publish to github you must set the "github_repository.owner" and "github_repository.name" properties in your forge config. See the docs for more info'.red); // eslint-disable-line - process.exit(1); + throw 'In order to publish to github you must set the "github_repository.owner" and "github_repository.name" properties in your forge config. See the docs for more info'; // eslint-disable-line } const github = new GitHub(authToken);