Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jprichardson/node-fs-extra
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 32a65ffd9111829dbba15d79f1d27519c7dc96a6
Choose a base ref
...
head repository: jprichardson/node-fs-extra
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8.1.0
Choose a head ref
  • 9 commits
  • 32 files changed
  • 2 contributors

Commits on May 14, 2019

  1. 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
    RyanZim authored May 14, 2019
    Copy the full SHA
    fa661f3 View commit details
  2. Copy the full SHA
    f3a2eed View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7a8424e View commit details

Commits on May 23, 2019

  1. Use files array in package.json instead of .npmignore (#692)

    Whitelists are better than blacklists. Tested to ensure the same files
    are bundled with `npm pack`.
    RyanZim authored May 23, 2019
    Copy the full SHA
    fff04cb View commit details
  2. Clarify docs for remove*() (#690)

    Closes #659
    RyanZim authored May 23, 2019
    Copy the full SHA
    31e177a View commit details
  3. Add package-lock.json to .gitignore (#691)

    Lockfiles don't make much sense for libraries
    RyanZim authored May 23, 2019
    Copy the full SHA
    713c606 View commit details
  4. Travis config tweaks (#693)

    * Remove sudo: false from .travis.yml
    
    Not needed as per
    https://docs.travis-ci.com/user/reference/trusty/#container-based-infrastructure
    
    * Run linter on Node 12
    RyanZim authored May 23, 2019
    Copy the full SHA
    9f1c029 View commit details

Commits on Jun 28, 2019

  1. Use graceful-fs everywhere (#700)

    * Switch back to upgraded graceful-fs for copy & move
    
    Fixes #664
    Fixes #684
    
    * Use graceful-fs for emptyDir*()
    RyanZim authored Jun 28, 2019
    Copy the full SHA
    40c3d68 View commit details
  2. 8.1.0

    RyanZim committed Jun 28, 2019
    Copy the full SHA
    b7df7cc View commit details
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.nyc_output/
coverage/
node_modules/
package-lock.json

.idea
*.iml
11 changes: 0 additions & 11 deletions .npmignore

This file was deleted.

9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
sudo: false
language: node_js
os:
- linux
@@ -8,18 +7,20 @@ node_js:
- 8
- 9
- 10
- 11
- 12
env: TEST_SUITE=unit
matrix:
exclude:
- os: linux
node_js: 8
node_js: 12
include:
- os: linux
node_js: 8
node_js: 12
env: TEST_SUITE=full-ci
script: npm run-script $TEST_SUITE
after_success:
- if [ $TEST_SUITE = full-ci ]; then npm run coveralls; fi
cache:
directories:
- node_modules
- node_modules
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
8.1.0 / 2019-06-28
------------------

- Add support for promisified `fs.realpath.native` in Node v9.2+ ([#650](https://github.com/jprichardson/node-fs-extra/issues/650), [#682](https://github.com/jprichardson/node-fs-extra/pull/682))
- Update `graceful-fs` dependency ([#700](https://github.com/jprichardson/node-fs-extra/pull/700))
- Use `graceful-fs` everywhere ([#700](https://github.com/jprichardson/node-fs-extra/pull/700))

8.0.1 / 2019-05-13
------------------

2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -26,4 +26,4 @@ test_script:
build: off

cache:
- node_modules
- node_modules
2 changes: 1 addition & 1 deletion docs/remove-sync.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# removeSync(path)

Removes a file or directory. The directory can have contents. Like `rm -rf`.
Removes a file or directory. The directory can have contents. If the path does not exist, silently does nothing. Like `rm -rf`.

- `path` `<String>`

2 changes: 1 addition & 1 deletion docs/remove.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# remove(path[, callback])

Removes a file or directory. The directory can have contents. Like `rm -rf`.
Removes a file or directory. The directory can have contents. If the path does not exist, silently does nothing. Like `rm -rf`.

- `path` `<String>`
- `callback` `<Function>`
2 changes: 1 addition & 1 deletion lib/__tests__/promise.test.js
Original file line number Diff line number Diff line change
@@ -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')
})
}
})
2 changes: 1 addition & 1 deletion lib/copy-sync/__tests__/broken-symlink.test.js
Original file line number Diff line number Diff line change
@@ -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')
})
})

14 changes: 7 additions & 7 deletions lib/copy-sync/__tests__/copy-sync-file.test.js
Original file line number Diff line number Diff line change
@@ -136,15 +136,15 @@ 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)
})
})

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,22 +161,22 @@ 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)
})
})

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')
4 changes: 2 additions & 2 deletions lib/copy-sync/__tests__/copy-sync-preserve-timestamp.test.js
Original file line number Diff line number Diff line change
@@ -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 }))
})
})

2 changes: 1 addition & 1 deletion lib/copy-sync/__tests__/symlink.test.js
Original file line number Diff line number Diff line change
@@ -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)
}
6 changes: 2 additions & 4 deletions lib/copy-sync/copy-sync.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
'use strict'

// TODO: enable this once graceful-fs supports bigint option.
// const fs = require('graceful-fs')
const fs = require('fs')
const fs = require('graceful-fs')
const path = require('path')
const mkdirpSync = require('../mkdirs').mkdirsSync
const utimesSync = require('../util/utimes.js').utimesMillisSync
const stat = require('../util/stat')

function copySync (src, dest, opts) {
if (typeof opts === 'function') {
opts = {filter: opts}
opts = { filter: opts }
}

opts = opts || {}
4 changes: 2 additions & 2 deletions lib/copy/__tests__/copy-preserve-timestamp.test.js
Original file line number Diff line number Diff line change
@@ -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()
})
})
4 changes: 2 additions & 2 deletions lib/copy/__tests__/copy.test.js
Original file line number Diff line number Diff line change
@@ -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()
})
2 changes: 1 addition & 1 deletion lib/copy/__tests__/ncp/broken-symlink.test.js
Original file line number Diff line number Diff line change
@@ -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()
})
6 changes: 3 additions & 3 deletions lib/copy/__tests__/ncp/ncp.test.js
Original file line number Diff line number Diff line change
@@ -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,15 +85,15 @@ 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()
})
})

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()
})
2 changes: 1 addition & 1 deletion lib/copy/__tests__/ncp/symlink.test.js
Original file line number Diff line number Diff line change
@@ -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')
6 changes: 2 additions & 4 deletions lib/copy/copy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict'

// TODO: enable this once graceful-fs supports bigint option.
// const fs = require('graceful-fs')
const fs = require('fs')
const fs = require('graceful-fs')
const path = require('path')
const mkdirp = require('../mkdirs').mkdirs
const pathExists = require('../path-exists').pathExists
@@ -14,7 +12,7 @@ function copy (src, dest, opts, cb) {
cb = opts
opts = {}
} else if (typeof opts === 'function') {
opts = {filter: opts}
opts = { filter: opts }
}

cb = cb || function () {}
2 changes: 1 addition & 1 deletion lib/empty/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const u = require('universalify').fromCallback
const fs = require('fs')
const fs = require('graceful-fs')
const path = require('path')
const mkdir = require('../mkdirs')
const remove = require('../remove')
14 changes: 7 additions & 7 deletions lib/ensure/__tests__/symlink-paths.test.js
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions lib/fs/__tests__/realpath.test.js
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)
})
})
}
5 changes: 5 additions & 0 deletions lib/fs/index.js
Original file line number Diff line number Diff line change
@@ -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)
}
4 changes: 2 additions & 2 deletions lib/json/__tests__/output-json-sync.test.js
Original file line number Diff line number Diff line change
@@ -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'))
Loading