Skip to content

Commit

Permalink
Accept spawnOptions first, specs after
Browse files Browse the repository at this point in the history
  • Loading branch information
rgbkrk committed Mar 26, 2016
1 parent 334684a commit 9602160
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,15 @@ function writeConnectionFile(portFinderOptions) {
* @param {object} kernelSpec describes a specific
* kernel, see the npm
* package `kernelspecs`
* @param {object} [portFinderOptions] connection options
* see {@link https://github.com/indexzero/node-portfinder/blob/master/lib/portfinder.js }
* @param {number} [portFinderOptions.port]
* @param {string} [portFinderOptions.host]
* @param {object} [spawnOptions] options for [child_process.spawn]{@link https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options}
* @return {object} spawnResults
* @return {ChildProcess} spawnResults.spawn spawned process
* @return {string} spawnResults.connectionFile connection file path
* @return {object} spawnResults.config connectionConfig
*
*/
function launchSpec(kernelSpec, portFinderOptions, spawnOptions) {
return writeConnectionFile(portFinderOptions).then((c) => {
function launchSpec(kernelSpec, spawnOptions) {
return writeConnectionFile().then((c) => {
const connectionFile = c.connectionFile;
const config = c.config;
const argv = kernelSpec.argv.map(x => x === '{connection_file}' ? connectionFile : x);
Expand All @@ -145,21 +141,19 @@ function launchSpec(kernelSpec, portFinderOptions, spawnOptions) {
* @return {string} spawnResults.connectionFile connection file path
* @return {object} spawnResults.config connectionConfig
*/
function launch(kernelName, specs, spawnOptions) {
function launch(kernelName, spawnOptions, specs) {
// Let them pass in a cached specs file
if (!specs) {
return kernelspecs.findAll()
.then((sp) => launch(kernelName, sp, spawnOptions));
.then((sp) => launch(kernelName, spawnOptions, sp));
}
if (!specs[kernelName]) {
return Promise.reject(new Error(`No spec available for ${kernelName}`));
}
const spec = specs[kernelName].spec;
return launchSpec(spec, {}, spawnOptions);
return launchSpec(spec, spawnOptions);
}

module.exports = {
launch,
launchSpec,
writeConnectionFile,
};

0 comments on commit 9602160

Please sign in to comment.