0

fs モジュールのストリーム オブジェクトを使用しようとしています。しかし、うまくいかないようです。以下は、問題を再現するための私のコーヒースクリプトです。誰かがスクリプトをチェックして、これがバグなのか、それとも間違っているのか教えてください。前もって感謝します。この質問も PhantomJs グループに投稿しましたが、回答がありません。

fs = require 'fs'
data = 'test fs'
fs.write 'tex.txt',data,'w'

rfile = fs.open('rfile.txt','w')
rfile.writeLine('testLine')
rfile.flush
rfile.close
phantom.exit()
4

1 に答える 1

0

Ok I found my mistake. In coffee script, when calling the functions, that does not have any arguments should include parenthesis in the call. The below coffee script works.

fs = require 'fs'
data = 'test fs'
fs.write 'tex.txt',data,'w'

rfile = fs.open 'rfile.txt','w'
rfile.writeLine 'testLine'
rfile.flush()
rfile.close()
phantom.exit()
于 2013-04-04T10:03:03.237 に答える