mirror of https://github.com/lukechilds/node.git
Browse Source
- replace var with const. - remove successes var. - use assert.ifError() for handling all errors. - wrap all callbacks with common.mustCall(). PR-URL: https://github.com/nodejs/node/pull/10176 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>v4.x
committed by
Myles Borins
1 changed files with 14 additions and 23 deletions
@ -1,32 +1,23 @@ |
|||||
'use strict'; |
'use strict'; |
||||
var common = require('../common'); |
const common = require('../common'); |
||||
var assert = require('assert'); |
const assert = require('assert'); |
||||
|
|
||||
var path = require('path'); |
const path = require('path'); |
||||
var fs = require('fs'); |
const fs = require('fs'); |
||||
var successes = 0; |
|
||||
|
|
||||
var file = path.join(common.fixturesDir, 'a.js'); |
const file = path.join(common.fixturesDir, 'a.js'); |
||||
|
|
||||
fs.open(file, 'a', 0o777, function(err, fd) { |
fs.open(file, 'a', 0o777, common.mustCall(function(err, fd) { |
||||
if (err) throw err; |
assert.ifError(err); |
||||
|
|
||||
fs.fdatasyncSync(fd); |
fs.fdatasyncSync(fd); |
||||
successes++; |
|
||||
|
|
||||
fs.fsyncSync(fd); |
fs.fsyncSync(fd); |
||||
successes++; |
|
||||
|
|
||||
fs.fdatasync(fd, function(err) { |
fs.fdatasync(fd, common.mustCall(function(err) { |
||||
if (err) throw err; |
assert.ifError(err); |
||||
successes++; |
fs.fsync(fd, common.mustCall(function(err) { |
||||
fs.fsync(fd, function(err) { |
assert.ifError(err); |
||||
if (err) throw err; |
})); |
||||
successes++; |
})); |
||||
}); |
})); |
||||
}); |
|
||||
}); |
|
||||
|
|
||||
process.on('exit', function() { |
|
||||
assert.equal(4, successes); |
|
||||
}); |
|
||||
|
Loading…
Reference in new issue