1616
1717'use strict' ;
1818
19- var api = require ( '../api' ) ;
19+ var createSystem = require ( '../api' ) . createSystem ;
2020var Commands = require ( '../commands/commands' ) . Commands ;
2121var Types = require ( '../types/types' ) . Types ;
2222
@@ -81,7 +81,8 @@ var items = [
8181
8282/**
8383 * These are the commands stored on the remote side that have converters which
84- * we'll need to present the data
84+ * we'll need to present the data. Ideally connection.specs would transfer
85+ * these, that doesn't happen yet so we add them manually
8586 */
8687var requiredConverters = [
8788 require ( '../cli' ) . items ,
@@ -107,21 +108,20 @@ var requiredConverters = [
107108exports . connect = function ( options ) {
108109 options = options || { } ;
109110
110- var system = api . createSystem ( ) ;
111-
111+ var system = createSystem ( ) ;
112112 system . addItems ( items ) ;
113113 system . addItems ( requiredConverters ) ;
114114
115115 var connector = system . connectors . get ( options . connector ) ;
116116 return connector . connect ( options . url ) . then ( function ( connection ) {
117- options . connection = connection ;
117+ system . connection = connection ;
118118 connection . on ( 'commandsChanged' , function ( specs ) {
119119 exports . addItems ( system , specs , connection ) ;
120120 } ) ;
121121
122122 return connection . call ( 'specs' ) . then ( function ( specs ) {
123123 exports . addItems ( system , specs , connection ) ;
124- return connection ;
124+ return system ;
125125 } ) ;
126126 } ) ;
127127} ;
@@ -144,8 +144,11 @@ exports.addLocalFunctions = function(specs, connection) {
144144 // in removeRemoteItems() below
145145 commandSpec . connection = connection ;
146146
147+ // TODO: removeRemoteItems() doesn't remove types, so do we need this?
147148 commandSpec . params . forEach ( function ( param ) {
148- param . type . connection = connection ;
149+ if ( typeof param . type !== 'string' ) {
150+ param . type . connection = connection ;
151+ }
149152 } ) ;
150153
151154 if ( ! commandSpec . isParent ) {
0 commit comments