Skip to content

Commit 8dfaba0

Browse files
committed
fix strange closure thing that was broken (using this.iterate as a callback)
1 parent 299ef9d commit 8dfaba0

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

bin/espruino-cli.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -813,20 +813,15 @@ function startConnect() {
813813
terminal(path, tasksComplete);
814814
});
815815
} else {
816-
//closure for stepping through each port
817-
//and connect + upload (use timeout callback [iterate] for proceeding)
818-
(function (ports, connect) {
819-
this.ports = ports;
820-
this.idx = 0;
821-
this.connect = connect;
822-
this.iterate = function() {
823-
if (this.idx>=ports.length) tasksComplete();
824-
else getPortPath(ports[this.idx++], function(path) {
825-
connect(path, this.iterate);
826-
});
827-
};
828-
this.iterate();
829-
})(args.ports, connect);
816+
// stepping through each port and connect + upload
817+
let ports = args.ports, idx = 0;
818+
let iterate = function() {
819+
if (idx>=ports.length) tasksComplete();
820+
else getPortPath(ports[idx++], function(path) {
821+
connect(path, iterate);
822+
});
823+
};
824+
iterate();
830825
}
831826
}
832827

0 commit comments

Comments
 (0)