[Pkg-javascript-commits] [node-fs-extra] 01/03: New upstream version 4.0.1

Julien Puydt julien.puydt at laposte.net
Sun Aug 6 07:00:03 UTC 2017


This is an automated email from the git hooks/post-receive script.

jpuydt-guest pushed a commit to branch master
in repository node-fs-extra.

commit cebb05243ba23134d407cf46d00d377e98db211e
Author: Julien Puydt <julien.puydt at laposte.net>
Date:   Sun Aug 6 08:56:41 2017 +0200

    New upstream version 4.0.1
---
 CHANGELOG.md                        | 15 +++++++++++----
 lib/ensure/__tests__/ensure.test.js | 29 +++++++++++++++++++++++++++++
 lib/ensure/file.js                  | 11 +++++++----
 package.json                        |  2 +-
 4 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 70efd66..ad514e5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,15 +1,22 @@
+4.0.1 / 2017-07-31
+------------------
+
+### Fixed
+
+- Previously, `ensureFile()` & `ensureFileSync()` would do nothing if the path was a directory. Now, they error out for consistency with `ensureDir()`. [#465](https://github.com/jprichardson/node-fs-extra/issues/465), [#466](https://github.com/jprichardson/node-fs-extra/pull/466), [#470](https://github.com/jprichardson/node-fs-extra/issues/470)
+
 4.0.0 / 2017-07-14
 ------------------
 
 ### Changed
 
-- **BREAKING:** The promisified versions of `fs.read()` & `fs.write()` now return objects. See [the docs](docs/fs-read-write.md) for details.
-- `fs.move()` now errors out when source and destination are the same.
-- Applied upstream fixes from `rimraf` to `fs.remove()` & `fs.removeSync()`.
+- **BREAKING:** The promisified versions of `fs.read()` & `fs.write()` now return objects. See [the docs](docs/fs-read-write.md) for details. [#436](https://github.com/jprichardson/node-fs-extra/issues/436), [#449](https://github.com/jprichardson/node-fs-extra/pull/449)
+- `fs.move()` now errors out when destination is a subdirectory of source. [#458](https://github.com/jprichardson/node-fs-extra/pull/458)
+- Applied upstream fixes from `rimraf` to `fs.remove()` & `fs.removeSync()`. [#459](https://github.com/jprichardson/node-fs-extra/pull/459)
 
 ### Fixed
 
-- Got `fs.outputJSONSync()` working again; it was broken due to refactoring.
+- Got `fs.outputJSONSync()` working again; it was broken due to refactoring. [#428](https://github.com/jprichardson/node-fs-extra/pull/428)
 
 Also clarified the docs in a few places.
 
diff --git a/lib/ensure/__tests__/ensure.test.js b/lib/ensure/__tests__/ensure.test.js
index b7b519e..0c06597 100644
--- a/lib/ensure/__tests__/ensure.test.js
+++ b/lib/ensure/__tests__/ensure.test.js
@@ -45,6 +45,19 @@ describe('fs-extra', () => {
         })
       })
     })
+
+    describe('> when there is a directory at that path', () => {
+      it('should error', done => {
+        const p = path.join(TEST_DIR, 'somedir')
+        fs.mkdirSync(p)
+
+        fse.ensureFile(p, err => {
+          assert(err)
+          assert.equal(err.code, 'EISDIR')
+          done()
+        })
+      })
+    })
   })
 
   describe('+ ensureFileSync()', () => {
@@ -68,6 +81,22 @@ describe('fs-extra', () => {
         assert(fs.existsSync(file))
       })
     })
+
+    describe('> when there is a directory at that path', () => {
+      it('should error', () => {
+        const p = path.join(TEST_DIR, 'somedir2')
+        fs.mkdirSync(p)
+
+        assert.throws(() => {
+          try {
+            fse.ensureFileSync(p)
+          } catch (e) {
+            assert.equal(e.code, 'EISDIR')
+            throw e
+          }
+        })
+      })
+    })
   })
 
   describe('+ ensureDir()', () => {
diff --git a/lib/ensure/file.js b/lib/ensure/file.js
index 962c21c..67eed30 100644
--- a/lib/ensure/file.js
+++ b/lib/ensure/file.js
@@ -14,9 +14,8 @@ function createFile (file, callback) {
     })
   }
 
-  pathExists(file, (err, fileExists) => {
-    if (err) return callback(err)
-    if (fileExists) return callback()
+  fs.stat(file, (err, stats) => { // eslint-disable-line handle-callback-err
+    if (!err && stats.isFile()) return callback()
     const dir = path.dirname(file)
     pathExists(dir, (err, dirExists) => {
       if (err) return callback(err)
@@ -30,7 +29,11 @@ function createFile (file, callback) {
 }
 
 function createFileSync (file) {
-  if (fs.existsSync(file)) return
+  let stats
+  try {
+    stats = fs.statSync(file)
+  } catch (e) {}
+  if (stats && stats.isFile()) return
 
   const dir = path.dirname(file)
   if (!fs.existsSync(dir)) {
diff --git a/package.json b/package.json
index 89887b6..2586812 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "fs-extra",
-  "version": "4.0.0",
+  "version": "4.0.1",
   "description": "fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as mkdir -p, cp -r, and rm -rf.",
   "homepage": "https://github.com/jprichardson/node-fs-extra",
   "repository": {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-fs-extra.git



More information about the Pkg-javascript-commits mailing list