[Pkg-javascript-commits] [node-fs-extra] 01/07: New upstream version 4.0.2

Julien Puydt julien.puydt at laposte.net
Fri Sep 15 06:08:45 UTC 2017


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

jpuydt-guest pushed a commit to annotated tag debian/4.0.2-1
in repository node-fs-extra.

commit 882f3c696ae6aa780e49d82be66b6807aff780f9
Author: Julien Puydt <julien.puydt at laposte.net>
Date:   Fri Sep 15 07:22:07 2017 +0200

    New upstream version 4.0.2
---
 .travis.yml                                     | 16 ++++++-----
 CHANGELOG.md                                    |  7 +++++
 appveyor.yml                                    |  5 ++--
 docs/outputJson-sync.md                         |  1 +
 docs/outputJson.md                              |  1 +
 docs/writeJson-sync.md                          |  1 +
 docs/writeJson.md                               |  1 +
 lib/__tests__/promise.test.js                   |  4 +--
 lib/fs/__tests__/copyFile.test.js               | 33 +++++++++++++++++++++
 lib/fs/index.js                                 |  5 +++-
 lib/json/__tests__/jsonfile-integration.test.js | 17 +++++++++++
 lib/json/__tests__/promise-support.test.js      | 38 +++++++++++++++++++++++++
 package.json                                    |  8 +++---
 13 files changed, 120 insertions(+), 17 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 0cfd6a5..45752ef 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,16 +1,18 @@
 sudo: false
 language: node_js
-node_js:
-  - "4"
-  - "5"
-  - "6"
-  - "7"
 matrix:
   include:
+    - node_js: "4"
+    - node_js: "5"
+    # We run both lint and unit on Node 6
+    - node_js: "6"
+      env: TEST_SUITE=test
     - node_js: "7"
-      env: TEST_SUITE=lint
+    # We run coverage on Node 8
+    - node_js: "8"
+      env: TEST_SUITE=coverage
 env:
   - TEST_SUITE=unit
 script: npm run-script $TEST_SUITE
 after_success:
-  - if [ $TEST_SUITE = lint ]; then npm run coveralls; fi
+  - if [ $TEST_SUITE = coverage ]; then npm run coveralls; fi
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ad514e5..2fbada2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,10 @@
+4.0.2 / 2017-09-12
+------------------
+
+- Added `EOL` option to `writeJson*` & `outputJson*` (via upgrade to jsonfile v4)
+- Added promise support to [`fs.copyFile()`](https://nodejs.org/api/fs.html#fs_fs_copyfile_src_dest_flags_callback) in Node 8.5+
+- Added `.js` extension to `main` field in `package.json` for better tooling compatibility. [#485](https://github.com/jprichardson/node-fs-extra/pull/485)
+
 4.0.1 / 2017-07-31
 ------------------
 
diff --git a/appveyor.yml b/appveyor.yml
index 8aeb13b..6c768ed 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -4,6 +4,7 @@ environment:
     # node.js
     - nodejs_version: "4"
     - nodejs_version: "6"
+    - nodejs_version: "8"
 
 # Install scripts. (runs after repo cloning)
 install:
@@ -18,8 +19,8 @@ test_script:
   # Output useful info for debugging.
   - node --version
   - npm --version
-  # run tests
-  - npm test
+  # run only unit tests; travis does the linting
+  - npm run unit
 
 # Don't actually build.
 build: off
diff --git a/docs/outputJson-sync.md b/docs/outputJson-sync.md
index 13c214d..ef78f80 100644
--- a/docs/outputJson-sync.md
+++ b/docs/outputJson-sync.md
@@ -8,6 +8,7 @@ Almost the same as [`writeJsonSync`](writeJson-sync.md), except that if the dire
 - `object` `<Object>`
 - `options` `<Object>`
   - `spaces` `<Number|String>` Number of spaces to indent; or a string to use for indentation (i.e. pass `'\t'` for tab indentation). See [the docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_space_argument) for more info.
+  - `EOL` `<String>` Set EOL character. Default is `\n`.
   - `replacer` [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter)
   - Also accepts [`fs.writeFileSync` options](https://nodejs.org/api/fs.html#fs_fs_writefilesync_file_data_options)
 
diff --git a/docs/outputJson.md b/docs/outputJson.md
index d3fbe67..7156991 100644
--- a/docs/outputJson.md
+++ b/docs/outputJson.md
@@ -8,6 +8,7 @@ Almost the same as [`writeJson`](writeJson.md), except that if the directory doe
 - `object` `<Object>`
 - `options` `<Object>`
   - `spaces` `<Number|String>` Number of spaces to indent; or a string to use for indentation (i.e. pass `'\t'` for tab indentation). See [the docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_space_argument) for more info.
+  - `EOL` `<String>` Set EOL character. Default is `\n`.
   - `replacer` [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter)
   - Also accepts [`fs.writeFile` options](https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback)
 - `callback` `<Function>`
diff --git a/docs/writeJson-sync.md b/docs/writeJson-sync.md
index d2a3ef6..c22459d 100644
--- a/docs/writeJson-sync.md
+++ b/docs/writeJson-sync.md
@@ -8,6 +8,7 @@ Writes an object to a JSON file.
 - `object` `<Object>`
 - `options` `<Object>`
   - `spaces` `<Number|String>` Number of spaces to indent; or a string to use for indentation (i.e. pass `'\t'` for tab indentation). See [the docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_space_argument) for more info.
+  - `EOL` `<String>` Set EOL character. Default is `\n`.
   - `replacer` [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter)
   - Also accepts [`fs.writeFileSync` options](https://nodejs.org/api/fs.html#fs_fs_writefilesync_file_data_options)
 
diff --git a/docs/writeJson.md b/docs/writeJson.md
index af94ffc..8e35271 100644
--- a/docs/writeJson.md
+++ b/docs/writeJson.md
@@ -8,6 +8,7 @@ Writes an object to a JSON file.
 - `object` `<Object>`
 - `options` `<Object>`
   - `spaces` `<Number|String>` Number of spaces to indent; or a string to use for indentation (i.e. pass `'\t'` for tab indentation). See [the docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_space_argument) for more info.
+  - `EOL` `<String>` Set EOL character. Default is `\n`.
   - `replacer` [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter)
   - Also accepts [`fs.writeFile` options](https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback)
 - `callback` `<Function>`
diff --git a/lib/__tests__/promise.test.js b/lib/__tests__/promise.test.js
index 80aeca5..724dbad 100644
--- a/lib/__tests__/promise.test.js
+++ b/lib/__tests__/promise.test.js
@@ -13,9 +13,7 @@ const methods = [
   'move',
   'readJson',
   'readJSON',
-  'remove',
-  'writeJson',
-  'writeJSON'
+  'remove'
 ]
 
 describe('promise support', () => {
diff --git a/lib/fs/__tests__/copyFile.test.js b/lib/fs/__tests__/copyFile.test.js
new file mode 100644
index 0000000..704bc53
--- /dev/null
+++ b/lib/fs/__tests__/copyFile.test.js
@@ -0,0 +1,33 @@
+'use strict'
+
+const os = require('os')
+const fs = require('fs')
+const fse = require('../..')
+const path = require('path')
+const assert = require('assert')
+
+/* eslint-env mocha */
+
+// Only availible in Node 8.5+
+if (typeof fs.copyFile === 'function') {
+  describe('fs.copyFile', () => {
+    let TEST_DIR
+
+    beforeEach(done => {
+      TEST_DIR = path.join(os.tmpdir(), 'fs-extra', 'fs-copyfile')
+      fse.emptyDir(TEST_DIR, done)
+    })
+
+    afterEach(done => fse.remove(TEST_DIR, done))
+
+    it('supports promises', () => {
+      const src = path.join(TEST_DIR, 'init.txt')
+      const dest = path.join(TEST_DIR, 'copy.txt')
+      fse.writeFileSync(src, 'hello')
+      return fse.copyFile(src, dest).then(() => {
+        const data = fse.readFileSync(dest, 'utf8')
+        assert.equal(data, 'hello')
+      })
+    })
+  })
+}
diff --git a/lib/fs/index.js b/lib/fs/index.js
index 551ca6a..4352965 100644
--- a/lib/fs/index.js
+++ b/lib/fs/index.js
@@ -34,7 +34,10 @@ const api = [
   'utimes',
   'writeFile'
 ]
-// fs.mkdtemp() was added in Node.js v5.10.0, so check if it exists
+// Add methods that are only in some Node.js versions
+// fs.copyFile was added in Node.js v8.5.0
+typeof fs.copyFile === 'function' && api.push('copyFile')
+// fs.mkdtemp() was added in Node.js v5.10.0
 typeof fs.mkdtemp === 'function' && api.push('mkdtemp')
 
 // Export all keys:
diff --git a/lib/json/__tests__/jsonfile-integration.test.js b/lib/json/__tests__/jsonfile-integration.test.js
index 64177de..15abe9f 100644
--- a/lib/json/__tests__/jsonfile-integration.test.js
+++ b/lib/json/__tests__/jsonfile-integration.test.js
@@ -31,4 +31,21 @@ describe('jsonfile-integration', () => {
       assert.strictEqual(data, JSON.stringify(obj1) + '\n')
     })
   })
+
+  describe('+ writeJsonSync / EOL', () => {
+    it('should read a file and parse the json', () => {
+      const obj1 = {
+        firstName: 'JP',
+        lastName: 'Richardson'
+      }
+
+      const file = path.join(TEST_DIR, 'file.json')
+      fse.writeJsonSync(file, obj1, { spaces: 2, EOL: '\r\n' })
+      const data = fs.readFileSync(file, 'utf8')
+      assert.strictEqual(
+        data,
+        JSON.stringify(obj1, null, 2).replace(/\n/g, '\r\n') + '\r\n'
+      )
+    })
+  })
 })
diff --git a/lib/json/__tests__/promise-support.test.js b/lib/json/__tests__/promise-support.test.js
new file mode 100644
index 0000000..f688f06
--- /dev/null
+++ b/lib/json/__tests__/promise-support.test.js
@@ -0,0 +1,38 @@
+'use strict'
+
+const fs = require('fs')
+const os = require('os')
+const fse = require(process.cwd())
+const path = require('path')
+const assert = require('assert')
+
+/* global afterEach, beforeEach, describe, it */
+
+describe('json promise support', () => {
+  let TEST_DIR
+
+  beforeEach(done => {
+    TEST_DIR = path.join(os.tmpdir(), 'fs-extra', 'json')
+    fse.emptyDir(TEST_DIR, done)
+  })
+
+  afterEach(done => fse.remove(TEST_DIR, done))
+
+  ;['writeJson', 'writeJSON'].forEach(method => {
+    describe(method, () => {
+      it('should support promises', () => {
+        const obj1 = {
+          firstName: 'JP',
+          lastName: 'Richardson'
+        }
+
+        const file = path.join(TEST_DIR, 'promise.json')
+        return fse[method](file, obj1)
+          .then(() => {
+            const data = fs.readFileSync(file, 'utf8')
+            assert.strictEqual(data, JSON.stringify(obj1) + '\n')
+          })
+      })
+    })
+  })
+})
diff --git a/package.json b/package.json
index 2586812..5150365 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "fs-extra",
-  "version": "4.0.1",
+  "version": "4.0.2",
   "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": {
@@ -34,7 +34,7 @@
   "license": "MIT",
   "dependencies": {
     "graceful-fs": "^4.1.2",
-    "jsonfile": "^3.0.0",
+    "jsonfile": "^4.0.0",
     "universalify": "^0.1.0"
   },
   "devDependencies": {
@@ -52,10 +52,10 @@
     "standard": "^10.0.2",
     "standard-markdown": "^4.0.1"
   },
-  "main": "./lib/index",
+  "main": "./lib/index.js",
   "scripts": {
     "coverage": "istanbul cover -i 'lib/**' -x '**/__tests__/**' test.js",
-    "coveralls": "npm run coverage && coveralls < coverage/lcov.info",
+    "coveralls": "coveralls < coverage/lcov.info",
     "lint": "standard && standard-markdown",
     "test-find": "find ./lib/**/__tests__ -name *.test.js | xargs mocha",
     "test": "npm run lint && npm run unit",

-- 
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