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: 7.0.0
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: 7.0.1
Choose a head ref
  • 7 commits
  • 7 files changed
  • 6 contributors

Commits on Aug 9, 2018

  1. Chore: github issue template (#617)

    * Chore: github issue template
    
    * Docs: typoe
    JPeer264 authored and jprichardson committed Aug 9, 2018

    Verified

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

Commits on Aug 11, 2018

  1. Show support for mode (#587)

    Node fs's mkdir supports mode specification. After reviewing the source
    fs-extra does as well, but is not documented. Update the documentation
    to include the `options` parameter and provide a few examples of using
    `mode`.
    robertjacobson authored and jprichardson committed Aug 11, 2018

    Verified

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

Commits on Oct 5, 2018

  1. Fix typo in docs (#628)

    alewitt authored and RyanZim committed Oct 5, 2018
    Copy the full SHA
    287f234 View commit details

Commits on Oct 30, 2018

  1. Added docs/ and CHANGELOG.md to .npmignore (#642) (#643)

    These files are not necessary.
    
    Closes #642
    AustinLeeGordon authored and RyanZim committed Oct 30, 2018
    Copy the full SHA
    ab254b1 View commit details

Commits on Nov 7, 2018

  1. Fix removeSync() to eliminate spurious ENOTEMPTY errors on Windows (#646

    )
    
    Fix removeSync() to measure its retry interval in milliseconds instead of CPU cycles
    pgonzal authored and RyanZim committed Nov 7, 2018
    Copy the full SHA
    ddc1a2f View commit details
  2. Copy the full SHA
    6392917 View commit details
  3. 7.0.1

    RyanZim committed Nov 7, 2018
    Copy the full SHA
    a32c852 View commit details
Showing with 78 additions and 26 deletions.
  1. +2 −1 .github/issue_template.md
  2. +2 −0 .npmignore
  3. +7 −0 CHANGELOG.md
  4. +15 −3 docs/ensureDir-sync.md
  5. +32 −2 docs/ensureDir.md
  6. +18 −18 lib/remove/rimraf.js
  7. +2 −2 package.json
3 changes: 2 additions & 1 deletion .github/issue_template.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!-- Please fill out the following information if it applies to your issue: -->
<!-- First ensure you installed the latest version of fs-extra -->
<!-- If your bug still exists please fill out the following information if it applies to your issue: -->
- **Operating System:**
- **Node.js version:**
- **`fs-extra` version:**
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -7,3 +7,5 @@ lib/**/__tests__/
test/readme.md
test.js
.github/
docs/
CHANGELOG.md
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
7.0.1 / 2018-11-07
------------------

- Fix `removeSync()` on Windows, in some cases, it would error out with `ENOTEMPTY` ([#646](https://github.com/jprichardson/node-fs-extra/pull/646))
- Document `mode` option for `ensureDir*()` ([#587](https://github.com/jprichardson/node-fs-extra/pull/587))
- Don't include documentation files in npm package tarball ([#642](https://github.com/jprichardson/node-fs-extra/issues/642), [#643](https://github.com/jprichardson/node-fs-extra/pull/643))

7.0.0 / 2018-07-16
------------------

18 changes: 15 additions & 3 deletions docs/ensureDir-sync.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
# ensureDirSync(dir)
# ensureDirSync(dir[,options])

Ensures that the directory exists. If the directory structure does not exist, it is created. Like `mkdir -p`.
Ensures that the directory exists. If the directory structure does not exist, it is created. Like `mkdir -p`. If provided, options may specify the desired mode for the directory.

**Aliases:** `mkdirsSync()`, `mkdirpSync()`

- `dir` `<String>`

- `options` `<Integer>|<Object>`
## Example:

```js
const fs = require('fs-extra')

const dir = '/tmp/this/path/does/not/exist'

const desiredMode = 0o2775
const options = {
mode: 0o2775
}

fs.ensureDirSync(dir)
// dir has now been created, including the directory it is to be placed in

fs.ensureDirSync(dir, desiredMode)
// dir has now been created, including the directory it is to be placed in with permission 0o2775

fs.ensureDirSync(dir, options)
// dir has now been created, including the directory it is to be placed in with permission 0o2775
```
34 changes: 32 additions & 2 deletions docs/ensureDir.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# ensureDir(dir, [callback])
# ensureDir(dir[,options][,callback])

Ensures that the directory exists. If the directory structure does not exist, it is created. Like `mkdir -p`.

**Aliases:** `mkdirs()`, `mkdirp()`

- `dir` `<String>`
- `options` `<Integer>|<Object>`
- `callback` `<Function>`

## Example:
@@ -13,13 +14,23 @@ Ensures that the directory exists. If the directory structure does not exist, it
const fs = require('fs-extra')

const dir = '/tmp/this/path/does/not/exist'
const desiredMode = 0o2775
const options = {
mode: 0o2775
}

// With a callback:
fs.ensureDir(dir, err => {
console.log(err) // => null
// dir has now been created, including the directory it is to be placed in
})

// With a callback and a mode integer
fs.ensureDir(dir, desiredMode, err => {
console.log(err) // => null
// dir has now been created with mode 0o2775, including the directory it is to be placed in
})

// With Promises:
fs.ensureDir(dir)
.then(() => {
@@ -29,6 +40,15 @@ fs.ensureDir(dir)
console.error(err)
})

// With Promises and a mode integer:
fs.ensureDir(dir, desiredMode)
.then(() => {
console.log('success!')
})
.catch(err => {
console.error(err)
})

// With async/await:
async function example (directory) {
try {
@@ -38,6 +58,16 @@ async function example (directory) {
console.error(err)
}
}

example(dir)

// With async/await and an options object, containing mode:
async function exampleMode (directory) {
try {
await fs.ensureDir(directory, options)
console.log('success!')
} catch (err) {
console.error(err)
}
}
exampleMode(dir)
```
36 changes: 18 additions & 18 deletions lib/remove/rimraf.js
Original file line number Diff line number Diff line change
@@ -290,24 +290,24 @@ function rmkidsSync (p, options) {
assert(options)
options.readdirSync(p).forEach(f => rimrafSync(path.join(p, f), options))

// We only end up here once we got ENOTEMPTY at least once, and
// at this point, we are guaranteed to have removed all the kids.
// So, we know that it won't be ENOENT or ENOTDIR or anything else.
// try really hard to delete stuff on windows, because it has a
// PROFOUNDLY annoying habit of not closing handles promptly when
// files are deleted, resulting in spurious ENOTEMPTY errors.
const retries = isWindows ? 100 : 1
let i = 0
do {
let threw = true
try {
const ret = options.rmdirSync(p, options)
threw = false
return ret
} finally {
if (++i < retries && threw) continue // eslint-disable-line
}
} while (true)
if (isWindows) {
// We only end up here once we got ENOTEMPTY at least once, and
// at this point, we are guaranteed to have removed all the kids.
// So, we know that it won't be ENOENT or ENOTDIR or anything else.
// try really hard to delete stuff on windows, because it has a
// PROFOUNDLY annoying habit of not closing handles promptly when
// files are deleted, resulting in spurious ENOTEMPTY errors.
const startTime = Date.now()
do {
try {
const ret = options.rmdirSync(p, options)
return ret
} catch (er) { }
} while (Date.now() - startTime < 500) // give up after 500ms
} else {
const ret = options.rmdirSync(p, options)
return ret
}
}

module.exports = rimraf
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fs-extra",
"version": "7.0.0",
"version": "7.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.",
"engines": {
"node": ">=6 <7 || >=8"
@@ -60,7 +60,7 @@
"full-ci": "npm run lint && npm run coverage",
"coverage": "istanbul cover -i 'lib/**' -x '**/__tests__/**' test.js",
"coveralls": "coveralls < coverage/lcov.info",
"lint": "standard && standard-markdown",
"lint": "standard",
"test-find": "find ./lib/**/__tests__ -name *.test.js | xargs mocha",
"test": "npm run lint && npm run unit",
"unit": "node test.js"