Skip to content

Commit

Permalink
Merge branch 'notifications-patch'
Browse files Browse the repository at this point in the history
  • Loading branch information
jargon committed Oct 11, 2017
2 parents 39dd03d + 4e4ce1f commit 88cc2b4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
20 changes: 14 additions & 6 deletions lib/atom-python-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,18 @@ module.exports = {
});
});

if (2 > args.length) {
atom.notifications.addError(`atom-python-run: \`FnKeyError\`: Invalid argument length for \`Fn-Key Command\`: requires \`repl [options] {file}\` formatting. Got \`${config.command}\` instead.`);
return;
}

if (config.extensions.length && !config.extensions.includes(info.ext)) {
atom.notifications.addError(`atom-python-run: \`ExtensionsError\`: \`extensions\` option has been enabled, but only \`${config.extensions}\` are allowed. Cowardly refusing to continue...`);
return;
}

if (config.pipeFile && ('' === config.pipePath || null == config.pipePath)) {
console.log("atom-python-run: `pipe` option has been enabled, but has no file to write to.");
console.log("Cowardly refusing to continue...");
atom.notifications.addError(`atom-python-run: \`PipeError\`: \`pipe\` option has been enabled, but has no \`file\` to write to. Cowardly refusing to continue...`);
return;
}

Expand Down Expand Up @@ -104,12 +109,15 @@ module.exports = {
}
});

if (null == tty) {
console.log('atom-python-run: ExceptionError: `terminal` refused to spawn a `tty` instance');
try {
tty.on('error', function (error) {
atom.notifications.addError(`atom-python-run: \`TerminalError\`: There was a problem opening \`${spawn.object.shell}\`. If your computer doesn't have \`${spawn.object.shell}\` installed, you can set your own terminal on the package's Settings.`);
});
tty.unref();
} catch(e) {
atom.notifications.addError(`atom-python-run: \`ExceptionError\`: \`terminal\` refused to spawn a \`tty\` instance: \`${e}\``);
return;
}

tty.unref();
}

this.subscriptions.add(...disposables);
Expand Down
8 changes: 0 additions & 8 deletions lib/terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,14 +330,6 @@ class SpawnWrapper extends Base {
tty(model) {
model.options = this.optionWrapper(model.options);
let tty = this.spawnWrapper(model);
let shellName = this.object.shell;

tty.on('error', function (error) {
atom.notifications.addError('There was a problem opening \''
+ shellName + '\'. If your computer doesn\'t have \'' + shellName
+ '\' installed, you can set your own terminal on the package\'s ' +
'Settings.')
});

if (model.log) {
new Log({
Expand Down

0 comments on commit 88cc2b4

Please sign in to comment.