Skip to content

Commit

Permalink
fix(generic): make all process.exit and console calls respect the int…
Browse files Browse the repository at this point in the history
…eractive setting

Fixes #111
  • Loading branch information
MarshallOfSound authored and malept committed Feb 1, 2017
1 parent f2c128e commit a3e4331
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
13 changes: 7 additions & 6 deletions src/api/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 \
Expand All @@ -221,4 +221,5 @@ Also please note if you are using \`preload\` scripts you need to follow the ste
at https:/electron-userland/electron-forge/wiki/Using-%27preload%27-scripts
Thanks for using ${'"electron-forge"'.green}!!!`);
}
};
2 changes: 1 addition & 1 deletion src/api/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 4 additions & 5 deletions src/api/make.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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') {
Expand Down
3 changes: 1 addition & 2 deletions src/publishers/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a3e4331

Please sign in to comment.