-
Notifications
You must be signed in to change notification settings - Fork 30.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- replace var with const. - remove successes var. - use assert.ifError() for handling all errors. - wrap all callbacks with common.mustCall().
- Loading branch information
Showing
1 changed file
with
14 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,23 @@ | ||
'use strict'; | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
|
||
var path = require('path'); | ||
var fs = require('fs'); | ||
var successes = 0; | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
var file = path.join(common.fixturesDir, 'a.js'); | ||
const file = path.join(common.fixturesDir, 'a.js'); | ||
|
||
fs.open(file, 'a', 0o777, function(err, fd) { | ||
if (err) throw err; | ||
fs.open(file, 'a', 0o777, common.mustCall(function(err, fd) { | ||
assert.ifError(err); | ||
|
||
fs.fdatasyncSync(fd); | ||
successes++; | ||
|
||
fs.fsyncSync(fd); | ||
successes++; | ||
|
||
fs.fdatasync(fd, function(err) { | ||
if (err) throw err; | ||
successes++; | ||
fs.fsync(fd, function(err) { | ||
if (err) throw err; | ||
successes++; | ||
}); | ||
}); | ||
}); | ||
|
||
process.on('exit', function() { | ||
assert.equal(4, successes); | ||
}); | ||
fs.fdatasync(fd, common.mustCall(function(err) { | ||
assert.ifError(err); | ||
fs.fsync(fd, common.mustCall(function(err) { | ||
assert.ifError(err); | ||
})); | ||
})); | ||
})); |