The execSync() as per the docs accepts an encoding value as options.const data = execSync( 'cat ./file.json', { encoding: 'utf8'} ); Also at various places I have seen using toString() instead:const data = execSync( 'cat ./file.json').toString(); In this stackoverflow question I have seen the usage of both at the same time: https://stackoverflow.com/questions/46818563/buffer-returned-by-child-process-execsync-is-incomplete?answertab=active#tab-topCan anyone clarify whats the difference in using that since I guess internally execSync uses readFileSync which then uses toString() only ?
Submitted August 19, 2020 at 02:34PM by Latter-Table3106
No comments:
Post a Comment