Socket
Socket
Sign inDemoInstall

fs-extra

Package Overview
Dependencies
3
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.30.0 to 1.0.0

lib/remove/rimraf.js

103

CHANGELOG.md

@@ -0,1 +1,34 @@

Unreleased
----------
### Added
### Removed
### Changed
### Fixed
1.0.0 / 2016-11-01
------------------
After five years of development, we finally have reach the 1.0.0 milestone! Big thanks goes
to [Ryan Zim](https://github.com/RyanZim) for leading the charge on this release!
### Added
- `walkSync()`
### Changed
- **BREAKING**: dropped Node v0.10 support.
- disabled `rimaf` globbing, wasn't used. [#280]
- deprecate `copy()/copySync()` option `filter` if it's a `RegExp`. `filter` should now be a function.
- inline `rimraf`. This is temporary and was done because `rimraf` depended upon the beefy `glob` which `fs-extra` does not use. [#300]
### Fixed
- bug fix proper closing of file handle on `utimesMillis()` [#271]
- proper escaping of files with dollar signs [#291]
- `copySync()` failed if user didn't own file. [#199], [#301]
0.30.0 / 2016-04-28

@@ -317,2 +350,72 @@ -------------------

[#307]: https://github.com/jprichardson/node-fs-extra/pull/307 "Fix coverage"
[#306]: https://github.com/jprichardson/node-fs-extra/pull/306 "Update devDeps, fix lint error"
[#305]: https://github.com/jprichardson/node-fs-extra/pull/305 "Re-add Coveralls"
[#304]: https://github.com/jprichardson/node-fs-extra/pull/304 "Remove path-is-absolute [enhancement]"
[#303]: https://github.com/jprichardson/node-fs-extra/pull/303 "Document copySync filter inconsistency [documentation, feature-copy]"
[#302]: https://github.com/jprichardson/node-fs-extra/pull/302 "fix(console): depreciated -> deprecated"
[#301]: https://github.com/jprichardson/node-fs-extra/pull/301 "Remove chmod call from copySync [feature-copy]"
[#300]: https://github.com/jprichardson/node-fs-extra/pull/300 "Inline Rimraf [enhancement, feature-move, feature-remove]"
[#299]: https://github.com/jprichardson/node-fs-extra/pull/299 "Warn when filter is a RegExp [feature-copy]"
[#298]: https://github.com/jprichardson/node-fs-extra/issues/298 "API Docs [documentation]"
[#297]: https://github.com/jprichardson/node-fs-extra/pull/297 "Warn about using preserveTimestamps on 32-bit node"
[#296]: https://github.com/jprichardson/node-fs-extra/pull/296 "Improve EEXIST error message for copySync [enhancement]"
[#295]: https://github.com/jprichardson/node-fs-extra/pull/295 "Depreciate using regular expressions for copy's filter option [documentation]"
[#294]: https://github.com/jprichardson/node-fs-extra/pull/294 "BREAKING: Refactor lib/copy/ncp.js [feature-copy]"
[#293]: https://github.com/jprichardson/node-fs-extra/pull/293 "Update CI configs"
[#292]: https://github.com/jprichardson/node-fs-extra/issues/292 "Rewrite lib/copy/ncp.js [enhancement, feature-copy]"
[#291]: https://github.com/jprichardson/node-fs-extra/pull/291 "Escape '$' in replacement string for async file copying"
[#290]: https://github.com/jprichardson/node-fs-extra/issues/290 "Exclude files pattern while copying using copy.config.js [question]"
[#289]: https://github.com/jprichardson/node-fs-extra/pull/289 "(Closes #271) lib/util/utimes: properly close file descriptors in the event of an error"
[#288]: https://github.com/jprichardson/node-fs-extra/pull/288 "(Closes #271) lib/util/utimes: properly close file descriptors in the event of an error"
[#287]: https://github.com/jprichardson/node-fs-extra/issues/287 "emptyDir() callback arguments are inconsistent [enhancement, feature-remove]"
[#286]: https://github.com/jprichardson/node-fs-extra/pull/286 "Added walkSync function"
[#285]: https://github.com/jprichardson/node-fs-extra/issues/285 "CITGM test failing on s390"
[#284]: https://github.com/jprichardson/node-fs-extra/issues/284 "outputFile method is missing a check to determine if existing item is a folder or not"
[#283]: https://github.com/jprichardson/node-fs-extra/pull/283 "Apply filter also on directories and symlinks for copySync()"
[#282]: https://github.com/jprichardson/node-fs-extra/pull/282 "Apply filter also on directories and symlinks for copySync()"
[#281]: https://github.com/jprichardson/node-fs-extra/issues/281 "remove function executes "successfully" but doesn't do anything?"
[#280]: https://github.com/jprichardson/node-fs-extra/pull/280 "Disable rimraf globbing"
[#279]: https://github.com/jprichardson/node-fs-extra/issues/279 "Some code is vendored instead of included [awaiting-reply]"
[#278]: https://github.com/jprichardson/node-fs-extra/issues/278 "copy() does not preserve file/directory ownership"
[#277]: https://github.com/jprichardson/node-fs-extra/pull/277 "Mention defaults for clobber and dereference options"
[#276]: https://github.com/jprichardson/node-fs-extra/issues/276 "Cannot connect to Shared Folder [awaiting-reply]"
[#275]: https://github.com/jprichardson/node-fs-extra/issues/275 "EMFILE, too many open files on Mac OS with JSON API"
[#274]: https://github.com/jprichardson/node-fs-extra/issues/274 "Use with memory-fs? [enhancement, future]"
[#273]: https://github.com/jprichardson/node-fs-extra/pull/273 "tests: rename `remote.test.js` to `remove.test.js`"
[#272]: https://github.com/jprichardson/node-fs-extra/issues/272 "Copy clobber flag never err even when true [bug, feature-copy]"
[#271]: https://github.com/jprichardson/node-fs-extra/issues/271 "Unclosed file handle on futimes error"
[#270]: https://github.com/jprichardson/node-fs-extra/issues/270 "copy not working as desired on Windows [feature-copy, platform-windows]"
[#269]: https://github.com/jprichardson/node-fs-extra/issues/269 "Copying with preserveTimeStamps: true is inaccurate using 32bit node [feature-copy]"
[#268]: https://github.com/jprichardson/node-fs-extra/pull/268 "port fix for mkdirp issue #111"
[#267]: https://github.com/jprichardson/node-fs-extra/issues/267 "WARN deprecated wrench@1.5.9: wrench.js is deprecated!"
[#266]: https://github.com/jprichardson/node-fs-extra/issues/266 "fs-extra"
[#265]: https://github.com/jprichardson/node-fs-extra/issues/265 "Link the `fs.stat fs.exists` etc. methods for replace the `fs` module forever?"
[#264]: https://github.com/jprichardson/node-fs-extra/issues/264 "Renaming a file using move fails when a file inside is open (at least on windows) [wont-fix]"
[#263]: https://github.com/jprichardson/node-fs-extra/issues/263 "ENOSYS: function not implemented, link [needs-confirmed]"
[#262]: https://github.com/jprichardson/node-fs-extra/issues/262 "Add .exists() and .existsSync()"
[#261]: https://github.com/jprichardson/node-fs-extra/issues/261 "Cannot read property 'prototype' of undefined"
[#260]: https://github.com/jprichardson/node-fs-extra/pull/260 "use more specific path for method require"
[#259]: https://github.com/jprichardson/node-fs-extra/issues/259 "Feature Request: isEmpty"
[#258]: https://github.com/jprichardson/node-fs-extra/issues/258 "copy files does not preserve file timestamp"
[#257]: https://github.com/jprichardson/node-fs-extra/issues/257 "Copying a file on windows fails"
[#256]: https://github.com/jprichardson/node-fs-extra/pull/256 "Updated Readme "
[#255]: https://github.com/jprichardson/node-fs-extra/issues/255 "Update rimraf required version"
[#254]: https://github.com/jprichardson/node-fs-extra/issues/254 "request for readTree, readTreeSync, walkSync method"
[#253]: https://github.com/jprichardson/node-fs-extra/issues/253 "outputFile does not touch mtime when file exists"
[#252]: https://github.com/jprichardson/node-fs-extra/pull/252 "Fixing problem when copying file with no write permission"
[#251]: https://github.com/jprichardson/node-fs-extra/issues/251 "Just wanted to say thank you"
[#250]: https://github.com/jprichardson/node-fs-extra/issues/250 "`fs.remove()` not removing files (works with `rm -rf`)"
[#249]: https://github.com/jprichardson/node-fs-extra/issues/249 "Just a Question ... Remove Servers"
[#248]: https://github.com/jprichardson/node-fs-extra/issues/248 "Allow option to not preserve permissions for copy"
[#247]: https://github.com/jprichardson/node-fs-extra/issues/247 "Add TypeScript typing directly in the fs-extra package"
[#246]: https://github.com/jprichardson/node-fs-extra/issues/246 "fse.remove() && fse.removeSync() don't throw error on ENOENT file"
[#245]: https://github.com/jprichardson/node-fs-extra/issues/245 "filter for empty dir [enhancement]"
[#244]: https://github.com/jprichardson/node-fs-extra/issues/244 "copySync doesn't apply the filter to directories"
[#243]: https://github.com/jprichardson/node-fs-extra/issues/243 "Can I request fs.walk() to be synchronous?"
[#242]: https://github.com/jprichardson/node-fs-extra/issues/242 "Accidentally truncates file names ending with $$ [bug, feature-copy]"
[#241]: https://github.com/jprichardson/node-fs-extra/pull/241 "Remove link to createOutputStream"
[#240]: https://github.com/jprichardson/node-fs-extra/issues/240 "walkSync request"
[#239]: https://github.com/jprichardson/node-fs-extra/issues/239 "Depreciate regular expressions for copy's filter [documentation, feature-copy]"
[#238]: https://github.com/jprichardson/node-fs-extra/issues/238 "Can't write to files while in a worker thread."

@@ -319,0 +422,0 @@ [#237]: https://github.com/jprichardson/node-fs-extra/issues/237 ".ensureDir(..) fails silently when passed an invalid path..."

7

lib/copy-sync/copy-file-sync.js

@@ -12,6 +12,9 @@ var fs = require('graceful-fs')

if (clobber) {
fs.chmodSync(destFile, parseInt('777', 8))
fs.unlinkSync(destFile)
} else {
throw Error('EEXIST')
var err = new Error('EEXIST: ' + destFile + ' already exists.')
err.code = 'EEXIST'
err.errno = -17
err.path = destFile
throw err
}

@@ -18,0 +21,0 @@ }

@@ -21,2 +21,8 @@ var fs = require('graceful-fs')

// Warn about using preserveTimestamps on 32-bit node:
if (options.preserveTimestamps && process.arch === 'ia32') {
console.warn('fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n' +
'see https://github.com/jprichardson/node-fs-extra/issues/269')
}
var stats = (options.recursive && !options.dereference) ? fs.lstatSync(src) : fs.statSync(src)

@@ -28,4 +34,6 @@ var destFolder = path.dirname(dest)

if (stats.isFile()) {
if (options.filter instanceof RegExp) performCopy = options.filter.test(src)
else if (typeof options.filter === 'function') performCopy = options.filter(src)
if (options.filter instanceof RegExp) {
console.warn('Warning: fs-extra: Passing a RegExp filter is deprecated, use a function')
performCopy = options.filter.test(src)
} else if (typeof options.filter === 'function') performCopy = options.filter(src)

@@ -32,0 +40,0 @@ if (performCopy) {

@@ -16,2 +16,8 @@ var fs = require('graceful-fs')

// Warn about using preserveTimestamps on 32-bit node:
if (options.preserveTimestamps && process.arch === 'ia32') {
console.warn('fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n' +
'see https://github.com/jprichardson/node-fs-extra/issues/269')
}
// don't allow src and dest to be the same

@@ -18,0 +24,0 @@ var basePath = process.cwd()

@@ -19,15 +19,12 @@ // imported from ncp (this is temporary, will rewrite)

var transform = options.transform
var clobber = options.clobber !== false
var clobber = options.clobber !== false // default true
var dereference = options.dereference
var preserveTimestamps = options.preserveTimestamps === true
var errs = null
var started = 0
var finished = 0
var running = 0
// this is pretty useless now that we're using graceful-fs
// consider removing
var limit = options.limit || 512
var errored = false
startCopy(currentPath)

@@ -39,2 +36,3 @@

if (filter instanceof RegExp) {
console.warn('Warning: fs-extra: Passing a RegExp filter is deprecated, use a function')
if (!filter.test(source)) {

@@ -54,7 +52,2 @@ return doneOne(true)

var stat = dereference ? fs.stat : fs.lstat
if (running >= limit) {
return setImmediate(function () {
getStats(source)
})
}
running++

@@ -85,3 +78,3 @@ stat(source, function (err, stats) {

function onFile (file) {
var target = file.name.replace(currentPath, targetPath)
var target = file.name.replace(currentPath, targetPath.replace('$', '$$$$')) // escapes '$' with '$$'
isWritable(target, function (writable) {

@@ -96,3 +89,7 @@ if (writable) {

} else {
doneOne()
var err = new Error('EEXIST: ' + target + ' already exists.')
err.code = 'EEXIST'
err.errno = -17
err.path = target
onError(err)
}

@@ -141,3 +138,3 @@ }

function onDir (dir) {
var target = dir.name.replace(currentPath, targetPath)
var target = dir.name.replace(currentPath, targetPath.replace('$', '$$$$')) // escapes '$' with '$$'
isWritable(target, function (writable) {

@@ -223,15 +220,7 @@ if (writable) {

function onError (err) {
if (options.stopOnError) {
// ensure callback is defined & called only once:
if (!errored && callback !== undefined) {
errored = true
return callback(err)
} else if (!errs && options.errs) {
errs = fs.createWriteStream(options.errs)
} else if (!errs) {
errs = []
}
if (typeof errs.write === 'undefined') {
errs.push(err)
} else {
errs.write(err.stack + '\n\n')
}
return doneOne()
}

@@ -244,3 +233,3 @@

if (callback !== undefined) {
return errs ? callback(errs) : callback(null)
return callback(null)
}

@@ -247,0 +236,0 @@ }

var path = require('path')
// path.isAbsolute shim for Node.js 0.10 support
path.isAbsolute = (path.isAbsolute) ? path.isAbsolute : require('path-is-absolute')
var fs = require('graceful-fs')

@@ -5,0 +4,0 @@

@@ -23,2 +23,3 @@ var assign = require('./util/assign')

assign(fs, require('./walk'))
assign(fs, require('./walk-sync'))

@@ -25,0 +26,0 @@ module.exports = fs

@@ -10,3 +10,3 @@ // most of this code was written by Andrew Kelley

var path = require('path')
var rimraf = require('rimraf')
var remove = require('../remove').remove
var mkdirp = require('../mkdirs').mkdirs

@@ -44,3 +44,3 @@

if (err.code === 'ENOTEMPTY' || err.code === 'EEXIST') {
rimraf(dest, function (err) {
remove(dest, function (err) {
if (err) return callback(err)

@@ -56,3 +56,3 @@ options.clobber = false // just clobbered it, no need to do it again

setTimeout(function () {
rimraf(dest, function (err) {
remove(dest, function (err) {
if (err) return callback(err)

@@ -148,3 +148,3 @@ options.clobber = false

if (errList) return callback(errList[0])
rimraf(source, callback)
remove(source, callback)
})

@@ -154,3 +154,3 @@ }

if (clobber) {
rimraf(dest, function (err) {
remove(dest, function (err) {
if (err) return callback(err)

@@ -157,0 +157,0 @@ startNcp()

@@ -1,9 +0,10 @@

var rimraf = require('rimraf')
var rimraf = require('./rimraf')
function removeSync (dir) {
return rimraf.sync(dir)
return rimraf.sync(dir, {disableGlob: true})
}
function remove (dir, callback) {
return callback ? rimraf(dir, callback) : rimraf(dir, function () {})
var options = {disableGlob: true}
return callback ? rimraf(dir, options, callback) : rimraf(dir, options, function () {})
}

@@ -10,0 +11,0 @@

@@ -57,5 +57,6 @@ var fs = require('graceful-fs')

if (err) return callback(err)
fs.futimes(fd, atime, mtime, function (err) {
if (err) return callback(err)
fs.close(fd, callback)
fs.futimes(fd, atime, mtime, function (futimesErr) {
fs.close(fd, function (closeErr) {
if (callback) callback(futimesErr || closeErr)
})
})

@@ -62,0 +63,0 @@ })

{
"name": "fs-extra",
"version": "0.30.0",
"version": "1.0.0",
"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.",

@@ -38,19 +38,19 @@ "homepage": "https://github.com/jprichardson/node-fs-extra",

"jsonfile": "^2.1.0",
"klaw": "^1.0.0",
"path-is-absolute": "^1.0.0",
"rimraf": "^2.2.8"
"klaw": "^1.0.0"
},
"devDependencies": {
"coveralls": "^2.11.2",
"istanbul": "^0.3.5",
"istanbul": "^0.4.5",
"minimist": "^1.1.1",
"mocha": "^2.1.0",
"mocha": "^3.1.2",
"proxyquire": "^1.7.10",
"read-dir-files": "^0.1.1",
"rimraf": "^2.2.8",
"secure-random": "^1.1.1",
"semver": "^4.3.6",
"standard": "^7.0.0-beta.0"
"semver": "^5.3.0",
"standard": "^8.5.0"
},
"main": "./lib/index",
"scripts": {
"coverage": "istanbul cover test.js",
"coverage": "istanbul cover -i 'lib/**' -x '**/__tests__/**' test.js",
"coveralls": "npm run coverage && coveralls < coverage/lcov.info",

@@ -57,0 +57,0 @@ "lint": "standard",

@@ -14,3 +14,3 @@ Node.js: fs-extra

**NOTE (2016-04-28):** Node v0.10 will be unsupported 2016-10-01. Node v0.12 will be unsupported on 2017-04-01.
**NOTE (2016-11-01):** Node v0.12 will be unsupported on 2016-12-31.

@@ -115,2 +115,3 @@

- [walk](#walk)
- [walkSync](#walkSyncDir)
- [writeJson](#writejsonfile-object-options-callback)

@@ -131,6 +132,6 @@ - [writeJsonSync](#writejsonfile-object-options-callback)

Options:
- clobber (boolean): overwrite existing file or directory
- dereference (boolean): dereference symlinks
- clobber (boolean): overwrite existing file or directory, default is `true`.
- dereference (boolean): dereference symlinks, default is `false`.
- preserveTimestamps (boolean): will set last modification and access times to the ones of the original source files, default is `false`.
- filter: Function or RegExp to filter copied files. If function, return true to include, false to exclude. If RegExp, same as function, where `filter` is `filter.test`.
- filter: Function to filter copied files. Return `true` to include, `false` to exclude. This can also be a RegExp, however this is deprecated (See [issue #239](https://github.com/jprichardson/node-fs-extra/issues/239) for background). _Warning: `copySync` currently applies the filter only to files (see [#180](https://github.com/jprichardson/node-fs-extra/issues/180)). This will be fixed in a future release._

@@ -422,4 +423,5 @@ Sync: `copySync()`

```js
var fs = require('fs-extra')
var items = [] // files, directories, symlinks, etc
fse.walk(TEST_DIR)
fs.walk(TEST_DIR)
.on('data', function (item) {

@@ -437,3 +439,4 @@ items.push(item.path)

var items = [] // files, directories, symlinks, etc
fse.walk(TEST_DIR)
var fs = require('fs-extra')
fs.walk(TEST_DIR)
.on('readable', function () {

@@ -455,3 +458,15 @@ var item

### walkSync(dir)
Lists all files inside a directory recursively
Examples:
```js
var fs = require('fs-extra')
var files = fs.walkSync('/home/jprichardson')
// files = ['/home/jprichardson/file1', '/home/jprichardson/dir1/file2']
```
### writeJson(file, object, [options], callback)

@@ -458,0 +473,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc