Skip to content

Commit

Permalink
Do not strip any space characters after the % character
Browse files Browse the repository at this point in the history
  • Loading branch information
cheton committed Oct 4, 2017
1 parent 0dcc7f2 commit 2c81fd7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const parseLine = (() => {
// Parse % commands for bCNC and CNCjs
// - %wait Wait until the planner queue is empty
if (letter === '%') {
result.cmds = (result.cmds || []).concat(`${letter}${argument}`);
result.cmds = (result.cmds || []).concat(line.trim());
continue;
}

Expand Down
8 changes: 8 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ describe('gcode-parser', () => {
expect(data.cmds).to.deep.equal(['%wait']);
}

{ // %msg Restart spindle
const data = parseLine('%msg Restart spindle');
expect(data).to.be.an('object');
expect(data.line).to.be.an('string');
expect(data.words).to.be.empty;
expect(data.cmds).to.deep.equal(['%msg Restart spindle']);
}

{ // %zsafe=10
const data = parseLine('%zsafe=10');
expect(data).to.be.an('object');
Expand Down

0 comments on commit 2c81fd7

Please sign in to comment.