Skip to content
Permalink
Browse files

fix(generic): make all process.exit and console calls respect the int…

…eractive setting

Fixes #111
  • Loading branch information
MarshallOfSound authored and malept committed Jan 31, 2017
1 parent f2c128e commit a3e43315c0f44e5f3754a72e7796de941e6a1f65
Showing with 13 additions and 14 deletions.
  1. +7 −6 src/api/import.js
  2. +1 −1 src/api/install.js
  3. +4 −5 src/api/make.js
  4. +1 −2 src/publishers/github.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}!!!`);
}
};
@@ -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) {
@@ -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') {
@@ -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);

0 comments on commit a3e4331

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