Skip to content

Commit

Permalink
Add config for jupyter binary path
Browse files Browse the repository at this point in the history
  • Loading branch information
gnestor committed Jan 5, 2016
1 parent afb802d commit 8e616ef
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,19 @@ import {CompositeDisposable} from 'atom';
import {delimiter} from 'path';
import Dispatcher from './dispatcher';
import NotebookEditor from './notebook-editor';
import NotebookEditorView from './notebook-editor-view';``
import NotebookEditorView from './notebook-editor-view';

export default {

config: {
jupyterPath: {
title: 'Path to jupyter binary',
description: '',
type: 'string',
default: 'usr/local/bin'
}
},

activate(state) {
// console.log('Activated');
fixPath();
Expand Down Expand Up @@ -57,19 +66,22 @@ export default {
};

function fixPath() {
let defaultPaths = [
'/usr/local/bin',
'/usr/bin',
'/bin',
'/usr/local/sbin',
'/usr/sbin',
'/sbin',
'./node_modules/.bin'
];
let jupyterPath = atom.config.get('jupyter-notebook.jupyterPath');
if (defaultPaths.indexOf(jupyterPath) < 0) defaultPaths.unshift(jupyterPath);
if (process.platform === 'darwin') {
process.env.PATH = process.env.PATH.split(delimiter).reduce((result, path) => {
if (!result.find(item => item === path)) result.push(path);
return result;
}, [
'/usr/local/bin',
'/usr/bin',
'/bin',
'/usr/local/sbin',
'/usr/sbin',
'/sbin',
'./node_modules/.bin'
]).join(delimiter);
}, defaultPaths).join(delimiter);
}
}

Expand Down

0 comments on commit 8e616ef

Please sign in to comment.