mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-09 12:15:34 -06:00
Change writeSync to async
This commit is contained in:
parent
853e9a2462
commit
214e21d05b
@ -370,20 +370,23 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function write(buffer: any, offset = 0) {
|
||||
let toWrite = buffer.length - offset;
|
||||
_fs.write(1, buffer, offset, toWrite, function(err: any, written: number, buffer: any){
|
||||
offset += written;
|
||||
if (toWrite > written) {
|
||||
write(buffer, offset);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
args: process.argv.slice(2),
|
||||
newLine: _os.EOL,
|
||||
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
|
||||
write(s: string): void {
|
||||
const buffer = new Buffer(s, "utf8");
|
||||
let offset = 0;
|
||||
let toWrite: number = buffer.length;
|
||||
let written = 0;
|
||||
// 1 is a standard descriptor for stdout
|
||||
while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) {
|
||||
offset += written;
|
||||
toWrite -= written;
|
||||
}
|
||||
write(buffer);
|
||||
},
|
||||
readFile,
|
||||
writeFile,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user