fix: handle case data = 0 in writeFile
This commit is contained in:
parent
f9c5473c49
commit
90db749ee5
|
@ -1869,7 +1869,6 @@ function writeFile(context, path, data, options, callback) {
|
||||||
return callback(new Errors.EINVAL('flags is not valid', path));
|
return callback(new Errors.EINVAL('flags is not valid', path));
|
||||||
}
|
}
|
||||||
|
|
||||||
data = data || '';
|
|
||||||
if(!Buffer.isBuffer(data)) {
|
if(!Buffer.isBuffer(data)) {
|
||||||
if(typeof data === 'number') {
|
if(typeof data === 'number') {
|
||||||
data = '' + data;
|
data = '' + data;
|
||||||
|
@ -1878,7 +1877,7 @@ function writeFile(context, path, data, options, callback) {
|
||||||
data = Buffer.from(data.toString());
|
data = Buffer.from(data.toString());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
data = Buffer.from(data, options.encoding || 'utf8');
|
data = Buffer.from(data || '', options.encoding || 'utf8');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue