Repository: jprichardson/node-fs-extra
Pull request #683 (2019-05-13 16:58:47)

Update CI configs to test new Node versions

coveralls: 
[![Coverage Status](https://coveralls.io/builds/23355381/badge)](https://coveralls.io/builds/23355381)

Coverage remained the same at 83.903% when pulling **419af910f4749e7ec1644f587a3b559a8f35b7e7 on travis** into **32a65ffd9111829dbba15d79f1d27519c7dc96a6 on master**.


Patch:
diff --git a/.travis.yml b/.travis.yml
index dcee24b..06eca1e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,6 +8,8 @@ node_js:
   - 8
   - 9
   - 10
+  - 11
+  - 12
 env: TEST_SUITE=unit
 matrix:
   exclude:
@@ -22,4 +24,4 @@ after_success:
   - if [ $TEST_SUITE = full-ci ]; then npm run coveralls; fi
 cache:
   directories:
-    - node_modules
\ No newline at end of file
+    - node_modules
diff --git a/appveyor.yml b/appveyor.yml
index 0268a6b..7b7a0a0 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -26,4 +26,4 @@ test_script:
 build: off
 
 cache:
-  - node_modules
\ No newline at end of file
+  - node_modules
diff --git a/lib/copy-sync/copy-sync.js b/lib/copy-sync/copy-sync.js
index 0ca35c8..bb70e81 100644
--- a/lib/copy-sync/copy-sync.js
+++ b/lib/copy-sync/copy-sync.js
@@ -10,7 +10,7 @@ const stat = require('../util/stat')
 
 function copySync (src, dest, opts) {
   if (typeof opts === 'function') {
-    opts = {filter: opts}
+    opts = { filter: opts }
   }
 
   opts = opts || {}
diff --git a/lib/copy/copy.js b/lib/copy/copy.js
index b5738b7..fdab802 100644
--- a/lib/copy/copy.js
+++ b/lib/copy/copy.js
@@ -14,7 +14,7 @@ function copy (src, dest, opts, cb) {
     cb = opts
     opts = {}
   } else if (typeof opts === 'function') {
-    opts = {filter: opts}
+    opts = { filter: opts }
   }
 
   cb = cb || function () {}
diff --git a/lib/fs/index.js b/lib/fs/index.js
index 8ffdf7b..a7b2292 100644
--- a/lib/fs/index.js
+++ b/lib/fs/index.js
@@ -102,3 +102,8 @@ exports.write = function (fd, buffer, ...args) {
     })
   })
 }
+
+// fs.realpath.native only available in Node v9.2+
+if (typeof fs.realpath.native === 'function') {
+  exports.realpath.native = u(fs.realpath.native)
+}
diff --git a/package.json b/package.json
index 462b244..fe78288 100644
--- a/package.json
+++ b/package.json
@@ -50,7 +50,7 @@
     "proxyquire": "^2.0.1",
     "read-dir-files": "^0.1.1",
     "semver": "^5.3.0",
-    "standard": "^11.0.1"
+    "standard": "^12.0.1"
   },
   "main": "./lib/index.js",
   "scripts": {


Test patch:
diff --git a/lib/__tests__/promise.test.js b/lib/__tests__/promise.test.js
index eb6ad33..2c13468 100644
--- a/lib/__tests__/promise.test.js
+++ b/lib/__tests__/promise.test.js
@@ -29,7 +29,7 @@ describe('promise support', () => {
     it('provides fse.promises API', () => {
       const desc = Object.getOwnPropertyDescriptor(fse, 'promises')
       assert.ok(desc)
-      assert.equal(typeof desc.get, 'function')
+      assert.strictEqual(typeof desc.get, 'function')
     })
   }
 })
diff --git a/lib/copy-sync/__tests__/broken-symlink.test.js b/lib/copy-sync/__tests__/broken-symlink.test.js
index a5e6d57..d6d5b57 100644
--- a/lib/copy-sync/__tests__/broken-symlink.test.js
+++ b/lib/copy-sync/__tests__/broken-symlink.test.js
@@ -28,7 +28,7 @@ describe('copy-sync / broken symlink', () => {
   })
 
   it('should throw an error when dereference=true', () => {
-    assert.throws(() => copySync(src, out, {dereference: true}), err => err.code === 'ENOENT')
+    assert.throws(() => copySync(src, out, { dereference: true }), err => err.code === 'ENOENT')
   })
 })
 
diff --git a/lib/copy-sync/__tests__/copy-sync-file.test.js b/lib/copy-sync/__tests__/copy-sync-file.test.js
index b1122a2..5044214 100644
--- a/lib/copy-sync/__tests__/copy-sync-file.test.js
+++ b/lib/copy-sync/__tests__/copy-sync-file.test.js
@@ -136,7 +136,7 @@ describe('+ copySync() / file', () => {
       describe('> when destination file does NOT exist', () => {
         describe('> when overwrite is true', () => {
           it('should copy the file and not throw an error', () => {
-            fs.copySync(src, dest, {overwrite: true})
+            fs.copySync(src, dest, { overwrite: true })
             const destData = fs.readFileSync(dest, 'utf8')
             assert.strictEqual(srcData, destData)
           })
@@ -144,7 +144,7 @@ describe('+ copySync() / file', () => {
 
         describe('> when overwrite is false', () => {
           it('should copy the file and not throw an error', () => {
-            fs.copySync(src, dest, {overwrite: false})
+            fs.copySync(src, dest, { overwrite: false })
             const destData = fs.readFileSync(dest, 'utf8')
             assert.strictEqual(srcData, destData)
           })
@@ -161,7 +161,7 @@ describe('+ copySync() / file', () => {
 
         describe('> when overwrite is true', () => {
           it('should copy the file and not throw an error', () => {
-            fs.copySync(src, dest, {overwrite: true})
+            fs.copySync(src, dest, { overwrite: true })
             destData = fs.readFileSync(dest, 'utf8')
             assert.strictEqual(srcData, destData)
           })
@@ -169,14 +169,14 @@ describe('+ copySync() / file', () => {
 
         describe('> when overwrite is false', () => {
           it('should not throw an error', () => {
-            fs.copySync(src, dest, {overwrite: false})
+            fs.copySync(src, dest, { overwrite: false })
 
             // copy never happened
             const destDataNew = fs.readFileSync(dest, 'utf8')
             assert.strictEqual(destData, destDataNew)
           })
           it('should throw an error when errorOnExist is true', () => {
-            assert.throws(() => fs.copySync(src, dest, {overwrite: false, errorOnExist: true}))
+            assert.throws(() => fs.copySync(src, dest, { overwrite: false, errorOnExist: true }))
 
             // copy never happened
             const destDataNew = fs.readFileSync(dest, 'utf8')
@@ -188,7 +188,7 @@ describe('+ copySync() / file', () => {
           it('should copy the file and not throw an error', () => {
             try {
               fs.chmodSync(dest, parseInt('444', 8))
-              fs.copySync(src, dest, {overwrite: true})
+              fs.copySync(src, dest, { overwrite: true })
               destData = fs.readFileSync(dest, 'utf8')
               assert.strictEqual(srcData, destData)
             } finally {
@@ -212,7 +212,7 @@ describe('+ copySync() / file', () => {
       })
 
       it('is an alias for overwrite', () => {
-        fs.copySync(src, dest, {clobber: false})
+        fs.copySync(src, dest, { clobber: false })
 
         // copy never happened
         const destDataNew = fs.readFileSync(dest, 'utf8')
diff --git a/lib/copy-sync/__tests__/copy-sync-preserve-timestamp.test.js b/lib/copy-sync/__tests__/copy-sync-preserve-timestamp.test.js
index aa8318d..39cda0c 100644
--- a/lib/copy-sync/__tests__/copy-sync-preserve-timestamp.test.js
+++ b/lib/copy-sync/__tests__/copy-sync-preserve-timestamp.test.js
@@ -32,8 +32,8 @@ describeIfPractical('copySync() - preserveTimestamps option', () => {
 
   describe('> when preserveTimestamps option is true', () => {
     it('should have the same timestamps on copy', () => {
-      fs.copySync(SRC, DEST, {preserveTimestamps: true})
-      FILES.forEach(testFile({preserveTimestamps: true}))
+      fs.copySync(SRC, DEST, { preserveTimestamps: true })
+      FILES.forEach(testFile({ preserveTimestamps: true }))
     })
   })
 
diff --git a/lib/copy-sync/__tests__/symlink.test.js b/lib/copy-sync/__tests__/symlink.test.js
index 1825eec..c6e5508 100644
--- a/lib/copy-sync/__tests__/symlink.test.js
+++ b/lib/copy-sync/__tests__/symlink.test.js
@@ -35,7 +35,7 @@ describe('copy-sync / symlink', () => {
 
   it('copies file contents when dereference=true', () => {
     try {
-      copySync(src, out, {dereference: true})
+      copySync(src, out, { dereference: true })
     } catch (err) {
       assert.ifError(err)
     }
diff --git a/lib/copy/__tests__/copy-preserve-timestamp.test.js b/lib/copy/__tests__/copy-preserve-timestamp.test.js
index 3e1e558..ba52cb4 100644
--- a/lib/copy/__tests__/copy-preserve-timestamp.test.js
+++ b/lib/copy/__tests__/copy-preserve-timestamp.test.js
@@ -33,8 +33,8 @@ describeIfPractical('copy() - preserve timestamp', () => {
 
   describe('> when timestamp option is true', () => {
     it('should have the same timestamps on copy', done => {
-      copy(SRC, DEST, {preserveTimestamps: true}, () => {
-        FILES.forEach(testFile({preserveTimestamps: true}))
+      copy(SRC, DEST, { preserveTimestamps: true }, () => {
+        FILES.forEach(testFile({ preserveTimestamps: true }))
         done()
       })
     })
diff --git a/lib/copy/__tests__/copy.test.js b/lib/copy/__tests__/copy.test.js
index 9c1ce7f..798bafd 100644
--- a/lib/copy/__tests__/copy.test.js
+++ b/lib/copy/__tests__/copy.test.js
@@ -38,7 +38,7 @@ describe('fs-extra', () => {
 
       fse.ensureFileSync(src)
       fse.ensureFileSync(dest)
-      fse.copy(src, dest, {overwrite: false, errorOnExist: true}, err => {
+      fse.copy(src, dest, { overwrite: false, errorOnExist: true }, err => {
         assert(err)
         done()
       })
@@ -50,7 +50,7 @@ describe('fs-extra', () => {
 
       fse.ensureFileSync(src)
       fse.ensureFileSync(dest)
-      fse.copy(src, dest, {overwrite: false, errorOnExist: true}, err => {
+      fse.copy(src, dest, { overwrite: false, errorOnExist: true }, err => {
         assert(err)
         done()
       })
diff --git a/lib/copy/__tests__/ncp/broken-symlink.test.js b/lib/copy/__tests__/ncp/broken-symlink.test.js
index 461fa85..572e821 100644
--- a/lib/copy/__tests__/ncp/broken-symlink.test.js
+++ b/lib/copy/__tests__/ncp/broken-symlink.test.js
@@ -31,7 +31,7 @@ describe('ncp broken symlink', () => {
   })
 
   it('should return an error when dereference=true', done => {
-    ncp(src, out, {dereference: true}, err => {
+    ncp(src, out, { dereference: true }, err => {
       assert.strictEqual(err.code, 'ENOENT')
       done()
     })
diff --git a/lib/copy/__tests__/ncp/ncp.test.js b/lib/copy/__tests__/ncp/ncp.test.js
index fab4bc3..d22d64d 100644
--- a/lib/copy/__tests__/ncp/ncp.test.js
+++ b/lib/copy/__tests__/ncp/ncp.test.js
@@ -72,7 +72,7 @@ describe('ncp', () => {
       })
 
       it('the copy is complete after callback', done => {
-        ncp(src, out, {overwrite: true}, err => {
+        ncp(src, out, { overwrite: true }, err => {
           fs.createReadStream = () => done(new Error('createReadStream after callback'))
 
           assert.ifError(err)
@@ -85,7 +85,7 @@ describe('ncp', () => {
       beforeEach(done => rimraf(out, done))
 
       it('works', cb => {
-        ncp(src, out, {overwrite: false}, err => {
+        ncp(src, out, { overwrite: false }, err => {
           assert.ifError(err)
           cb()
         })
@@ -93,7 +93,7 @@ describe('ncp', () => {
 
       it('should not error if files exist', cb => {
         ncp(src, out, () => {
-          ncp(src, out, {overwrite: false}, err => {
+          ncp(src, out, { overwrite: false }, err => {
             assert.ifError(err)
             cb()
           })
diff --git a/lib/copy/__tests__/ncp/symlink.test.js b/lib/copy/__tests__/ncp/symlink.test.js
index 87ec3f1..dc1d307 100644
--- a/lib/copy/__tests__/ncp/symlink.test.js
+++ b/lib/copy/__tests__/ncp/symlink.test.js
@@ -35,7 +35,7 @@ describe('ncp / symlink', () => {
   })
 
   it('copies file contents when dereference=true', done => {
-    ncp(src, out, {dereference: true}, err => {
+    ncp(src, out, { dereference: true }, err => {
       assert.ifError(err)
 
       const fileSymlinkPath = path.join(out, 'file-symlink')
diff --git a/lib/ensure/__tests__/symlink-paths.test.js b/lib/ensure/__tests__/symlink-paths.test.js
index 518b45d..8db4e85 100644
--- a/lib/ensure/__tests__/symlink-paths.test.js
+++ b/lib/ensure/__tests__/symlink-paths.test.js
@@ -38,16 +38,16 @@ describe('symlink-type', () => {
   })
 
   const tests = [
-    [['foo.txt', 'symlink.txt'], {toCwd: 'foo.txt', toDst: 'foo.txt'}], // smart && nodestyle
-    [['foo.txt', 'empty-dir/symlink.txt'], {toCwd: 'foo.txt', toDst: '../foo.txt'}], // smart
-    [['../foo.txt', 'empty-dir/symlink.txt'], {toCwd: 'foo.txt', toDst: '../foo.txt'}], // nodestyle
-    [['foo.txt', 'dir-bar/symlink.txt'], {toCwd: 'foo.txt', toDst: '../foo.txt'}], // smart
-    [['../foo.txt', 'dir-bar/symlink.txt'], {toCwd: 'foo.txt', toDst: '../foo.txt'}], // nodestyle
+    [['foo.txt', 'symlink.txt'], { toCwd: 'foo.txt', toDst: 'foo.txt' }], // smart && nodestyle
+    [['foo.txt', 'empty-dir/symlink.txt'], { toCwd: 'foo.txt', toDst: '../foo.txt' }], // smart
+    [['../foo.txt', 'empty-dir/symlink.txt'], { toCwd: 'foo.txt', toDst: '../foo.txt' }], // nodestyle
+    [['foo.txt', 'dir-bar/symlink.txt'], { toCwd: 'foo.txt', toDst: '../foo.txt' }], // smart
+    [['../foo.txt', 'dir-bar/symlink.txt'], { toCwd: 'foo.txt', toDst: '../foo.txt' }], // nodestyle
     // this is to preserve node's symlink capability these arguments say create
     // a link to 'dir-foo/foo.txt' this works because it exists this is unlike
     // the previous example with 'empty-dir' because 'empty-dir/foo.txt' does not exist.
-    [['foo.txt', 'dir-foo/symlink.txt'], {toCwd: 'dir-foo/foo.txt', toDst: 'foo.txt'}], // nodestyle
-    [['foo.txt', 'real-alpha/real-beta/real-gamma/symlink.txt'], {toCwd: 'foo.txt', toDst: '../../../foo.txt'}]
+    [['foo.txt', 'dir-foo/symlink.txt'], { toCwd: 'dir-foo/foo.txt', toDst: 'foo.txt' }], // nodestyle
+    [['foo.txt', 'real-alpha/real-beta/real-gamma/symlink.txt'], { toCwd: 'foo.txt', toDst: '../../../foo.txt' }]
   ]
 
   // formats paths to pass on multiple operating systems
diff --git a/lib/fs/__tests__/realpath.test.js b/lib/fs/__tests__/realpath.test.js
new file mode 100644
index 0000000..59ee6fa
--- /dev/null
+++ b/lib/fs/__tests__/realpath.test.js
@@ -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)
+    })
+  })
+}
diff --git a/lib/json/__tests__/output-json-sync.test.js b/lib/json/__tests__/output-json-sync.test.js
index a4bc8c5..671fe79 100644
--- a/lib/json/__tests__/output-json-sync.test.js
+++ b/lib/json/__tests__/output-json-sync.test.js
@@ -22,7 +22,7 @@ describe('json', () => {
       const file = path.join(TEST_DIR, 'this-dir', 'does-not', 'exist', 'file.json')
       assert(!fs.existsSync(file))
 
-      const data = {name: 'JP'}
+      const data = { name: 'JP' }
       outputJsonSync(file, data)
 
       assert(fs.existsSync(file))
@@ -37,7 +37,7 @@ describe('json', () => {
         assert(!fs.existsSync(file))
 
         const replacer = (k, v) => v === 'JP' ? 'Jon Paul' : v
-        const data = {name: 'JP'}
+        const data = { name: 'JP' }
 
         outputJsonSync(file, data, { replacer })
         const newData = JSON.parse(fs.readFileSync(file, 'utf8'))
diff --git a/lib/json/__tests__/output-json.test.js b/lib/json/__tests__/output-json.test.js
index f69108a..c98370b 100644
--- a/lib/json/__tests__/output-json.test.js
+++ b/lib/json/__tests__/output-json.test.js
@@ -22,7 +22,7 @@ describe('json', () => {
       const file = path.join(TEST_DIR, 'this-dir', 'prob-does-not', 'exist', 'file.json')
       assert(!fs.existsSync(file))
 
-      const data = {name: 'JP'}
+      const data = { name: 'JP' }
       outputJson(file, data, err => {
         if (err) return done(err)
 
@@ -38,7 +38,7 @@ describe('json', () => {
       const file = path.join(TEST_DIR, 'this-dir', 'prob-does-not', 'exist', 'file.json')
       assert(!fs.existsSync(file))
 
-      const data = {name: 'JP'}
+      const data = { name: 'JP' }
       return outputJson(file, data)
     })
 
@@ -48,7 +48,7 @@ describe('json', () => {
         assert(!fs.existsSync(file))
 
         const replacer = (k, v) => v === 'JP' ? 'Jon Paul' : v
-        const data = {name: 'JP'}
+        const data = { name: 'JP' }
 
         outputJson(file, data, { replacer }, err => {
           assert.ifError(err)
diff --git a/lib/move-sync/__tests__/move-sync.test.js b/lib/move-sync/__tests__/move-sync.test.js
index e4b97dd..13f5032 100644
--- a/lib/move-sync/__tests__/move-sync.test.js
+++ b/lib/move-sync/__tests__/move-sync.test.js
@@ -103,7 +103,7 @@ describe('moveSync()', () => {
     assert(fs.existsSync(dest))
 
     try {
-      fse.moveSync(src, dest, {overwrite: false})
+      fse.moveSync(src, dest, { overwrite: false })
     } catch (err) {
       assert.strictEqual(err.message, 'dest already exists.')
     }
@@ -116,7 +116,7 @@ describe('moveSync()', () => {
     // verify file exists already
     assert(fs.existsSync(dest))
 
-    fse.moveSync(src, dest, {overwrite: true})
+    fse.moveSync(src, dest, { overwrite: true })
 
     const contents = fs.readFileSync(dest, 'utf8')
     const expected = /^sonic the hedgehog\r?\n$/
@@ -137,7 +137,7 @@ describe('moveSync()', () => {
     assert(pathsBefore.indexOf('another-file') >= 0)
     assert(pathsBefore.indexOf('another-folder') >= 0)
 
-    fse.moveSync(src, dest, {overwrite: true})
+    fse.moveSync(src, dest, { overwrite: true })
 
     // verify dest does not have old stuff
     const pathsAfter = fs.readdirSync(dest)
@@ -198,7 +198,7 @@ describe('moveSync()', () => {
 
     setUpMockFs('EXDEV')
 
-    fse.moveSync(src, dest, {overwrite: true})
+    fse.moveSync(src, dest, { overwrite: true })
 
     const contents = fs.readFileSync(dest + '/another-folder/file3', 'utf8')
     const expected = /^knuckles\r?\n$/
@@ -228,7 +228,7 @@ describe('moveSync()', () => {
       // verify file exists already
       assert(fs.existsSync(dest))
 
-      fse.moveSync(src, dest, {clobber: true})
+      fse.moveSync(src, dest, { clobber: true })
 
       const contents = fs.readFileSync(dest, 'utf8')
       const expected = /^sonic the hedgehog\r?\n$/
diff --git a/lib/move/__tests__/move.test.js b/lib/move/__tests__/move.test.js
index 7ee2ac0..617ed0b 100644
--- a/lib/move/__tests__/move.test.js
+++ b/lib/move/__tests__/move.test.js
@@ -60,7 +60,7 @@ describe('+ move()', () => {
       // verify file exists already
       assert(fs.existsSync(dest))
 
-      fse.move(src, dest, {overwrite: true}, err => {
+      fse.move(src, dest, { overwrite: true }, err => {
         assert.ifError(err)
         fs.readFile(dest, 'utf8', (err, contents) => {
           const expected = /^sonic the hedgehog\r?\n$/
@@ -85,7 +85,7 @@ describe('+ move()', () => {
       assert(paths.indexOf('another-file') >= 0)
       assert(paths.indexOf('another-folder') >= 0)
 
-      fse.move(src, dest, {overwrite: true}, err => {
+      fse.move(src, dest, { overwrite: true }, err => {
         assert.ifError(err)
 
         // verify dest does not have old stuff
@@ -109,7 +109,7 @@ describe('+ move()', () => {
 
       setUpMockFs('EXDEV')
 
-      fse.move(src, dest, {overwrite: true}, err => {
+      fse.move(src, dest, { overwrite: true }, err => {
         assert.ifError(err)
         assert.strictEqual(fs.rename.callCount, 1)
 
@@ -190,7 +190,7 @@ describe('+ move()', () => {
       // verify file exists already
       assert(fs.existsSync(dest))
 
-      fse.move(src, dest, {overwrite: false}, err => {
+      fse.move(src, dest, { overwrite: false }, err => {
         assert.strictEqual(err.message, 'dest already exists.')
         done()
       })
@@ -281,7 +281,7 @@ describe('+ move()', () => {
       // verify file exists already
       assert(fs.existsSync(dest))
 
-      fse.move(src, dest, {clobber: true}, err => {
+      fse.move(src, dest, { clobber: true }, err => {
         assert.ifError(err)
         fs.readFile(dest, 'utf8', (err, contents) => {
           const expected = /^sonic the hedgehog\r?\n$/
diff --git a/lib/util/__tests__/utimes.test.js b/lib/util/__tests__/utimes.test.js
index f79199d..103661d 100644
--- a/lib/util/__tests__/utimes.test.js
+++ b/lib/util/__tests__/utimes.test.js
@@ -19,7 +19,7 @@ describe('utimes', () => {
     fse.emptyDir(TEST_DIR, done)
     // reset stubs
     gracefulFsStub = {}
-    utimes = proxyquire('../utimes', {'graceful-fs': gracefulFsStub})
+    utimes = proxyquire('../utimes', { 'graceful-fs': gracefulFsStub })
   })
 
   describe('hasMillisResSync()', () => {