-
Notifications
You must be signed in to change notification settings - Fork 773
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for fs.realpath.native in envs that support it (#682)
* Add support for fs.realpath.native in envs that support it * Add test for realpathSync.native * assert.equal -> assert.strictEqual
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use strict' | ||
|
||
const fs = require('fs') | ||
const fse = require('../..') | ||
const assert = require('assert') | ||
|
||
/* eslint-env mocha */ | ||
|
||
// fs.realpath.native only available in Node v9.2+ | ||
if (typeof fs.realpath.native === 'function') { | ||
describe('realpath.native', () => { | ||
it('works with callbacks', () => { | ||
fse.realpath.native(__dirname, (err, path) => { | ||
assert.ifError(err) | ||
assert.strictEqual(path, __dirname) | ||
}) | ||
}) | ||
|
||
it('works with promises', (done) => { | ||
fse.realpath.native(__dirname) | ||
.then(path => { | ||
assert.strictEqual(path, __dirname) | ||
done() | ||
}) | ||
.catch(done) | ||
}) | ||
|
||
it('works with sync version', () => { | ||
const path = fse.realpathSync.native(__dirname) | ||
assert.strictEqual(path, __dirname) | ||
}) | ||
}) | ||
} |
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