8000 fix stdout issue · TYPECASTINGSG/rpscript-api-basic@f4e3eed · GitHub
[go: up one dir, main page]

Skip to content

Commit f4e3eed

Browse files
committed
fix stdout issue
1 parent 0af2f1d commit f4e3eed

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,16 @@ export default class RPSBasic {
5454
*
5555
*/
5656
@rpsAction({verbName:'stdout'})
57-
async stdout(ctx:RpsContext,opts:{}, text:any) : Promise<any>{
57+
async stdout(ctx:RpsContext,opts:{}, text?:any) : Promise<any>{
5858
if(text){
5959
process.stdout.write(text);
6060
return text;
6161
}
6262
else {
63-
return process.stdout.write;
63+
return function (txt) {
64+
process.stdout.write(txt);
65+
return txt;
66+
}
6467
}
6568
}
6669

test/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ m.describe('Basic', () => {
2828
console.log(await basic.wait(context,{},1,'welcome'));
2929
console.log(await basic.wait(context,{},2,undefined));
3030

31-
await basic.stdout(context,{},'h');
31+
fn = await basic.stdout(context,{});
32+
fn('k');
3233
await basic.stdout(context,{},'e');
3334

3435

0 commit comments

Comments
 (0)
0