Skip to content

Commit 2c81fd7

Browse files
committed
Do not strip any space characters after the % character
1 parent 0dcc7f2 commit 2c81fd7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const parseLine = (() => {
101101
// Parse % commands for bCNC and CNCjs
102102
// - %wait Wait until the planner queue is empty
103103
if (letter === '%') {
104-
result.cmds = (result.cmds || []).concat(`${letter}${argument}`);
104+
result.cmds = (result.cmds || []).concat(line.trim());
105105
continue;
106106
}
107107

test/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ describe('gcode-parser', () => {
8181
expect(data.cmds).to.deep.equal(['%wait']);
8282
}
8383

84+
{ // %msg Restart spindle
85+
const data = parseLine('%msg Restart spindle');
86+
expect(data).to.be.an('object');
87+
expect(data.line).to.be.an('string');
88+
expect(data.words).to.be.empty;
89+
expect(data.cmds).to.deep.equal(['%msg Restart spindle']);
90+
}
91+
8492
{ // %zsafe=10
8593
const data = parseLine('%zsafe=10');
8694
expect(data).to.be.an('object');

0 commit comments

Comments
 (0)