Skip to content

Commit

Permalink
command: made --stdin end on ^D or ^Z for Windows; closes #204
Browse files Browse the repository at this point in the history
  • Loading branch information
satyr committed Feb 25, 2013
1 parent 139972d commit ace3e15
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
11 changes: 8 additions & 3 deletions lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,17 @@ function compileStdin(){
argv[1] = 'stdin';
x0$ = process.openStdin();
code = '';
x0$.on('data', function(it){
code += it;
});
x0$.on('end', function(){
compileScript('', code);
});
x0$.on('data', function(it){
var ref$;
if ((ref$ = it[0]) === 4 || ref$ === 26) {
x0$.emit('end');
x0$.destroy();
}
code += it;
});
}
function watch(source, action){
(function loop(ptime){
Expand Down
7 changes: 6 additions & 1 deletion src/command.co
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,13 @@ default
argv.1 = \stdin
process.openStdin!
code = ''
&on \data !-> code += it
&on \end !-> compileScript '' code
&on \data !->
# Detect __^D__ and __^Z__ for Windows.
if it.0 of [4 26]
&emit \end
&destroy!
code += it

# Watch a source Coco file using `setTimeout`, taking an `action` every
# time the file is updated.
Expand Down

0 comments on commit ace3e15

Please sign in to comment.