Skip to content

Commit d5b8051

Browse files
committed
Working on end-of-job behavior
1 parent 415f470 commit d5b8051

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

bin/g.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,11 @@ function tryToQuit() {
196196
}
197197

198198
var maxLineNumber = 0;
199-
function sendFile(fileName) {
199+
function sendFile(fileName, exitWhenDone) {
200+
if (exitWhenDone == null) {
201+
exitWhenDone = false;
202+
}
203+
200204
function startSendFile() {
201205
sendingFile = true;
202206
g.sendFile(fileName || process.stdin, function(err) {
@@ -210,16 +214,15 @@ function sendFile(fileName) {
210214
sendingFile = false;
211215
maxLineNumber = 0;
212216

213-
// FIX THIS!!
214-
// if (rl !== null) {
215-
// rl.close();
216-
// // rl = null;
217-
// }
218217
// log("closing...");
219-
if (!interactive) {
220-
g.close();
221-
}
218+
if (exitWhenDone == true) {
219+
if (rl !== null) {
220+
rl.close();
221+
rl = null;
222222

223+
g.close();
224+
}
225+
}
223226
});
224227
}
225228

@@ -439,7 +442,7 @@ function openTinyG() {
439442
}
440443

441444
if (args.gcode || !process.stdin.isTTY) {
442-
sendFile(args.gcode || process.stdin);
445+
sendFile(args.gcode || process.stdin, true);
443446
}
444447
}
445448

0 commit comments

Comments
 (0)