mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
7a0e462f9f
Manually fix issues that eslint --fix couldn't do automatically. PR-URL: https://github.com/nodejs/node/pull/10685 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
46 lines
915 B
JavaScript
46 lines
915 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
const fn = path.join(common.fixturesDir, 'empty.txt');
|
|
|
|
tempFd(function(fd, close) {
|
|
fs.readFile(fd, function(err, data) {
|
|
assert.ok(data);
|
|
close();
|
|
});
|
|
});
|
|
|
|
tempFd(function(fd, close) {
|
|
fs.readFile(fd, 'utf8', function(err, data) {
|
|
assert.strictEqual('', data);
|
|
close();
|
|
});
|
|
});
|
|
|
|
tempFdSync(function(fd) {
|
|
assert.ok(fs.readFileSync(fd));
|
|
});
|
|
|
|
tempFdSync(function(fd) {
|
|
assert.strictEqual('', fs.readFileSync(fd, 'utf8'));
|
|
});
|
|
|
|
function tempFd(callback) {
|
|
fs.open(fn, 'r', function(err, fd) {
|
|
assert.ifError(err);
|
|
callback(fd, function() {
|
|
fs.close(fd, function(err) {
|
|
assert.ifError(err);
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
function tempFdSync(callback) {
|
|
const fd = fs.openSync(fn, 'r');
|
|
callback(fd);
|
|
fs.closeSync(fd);
|
|
}
|