GithubHelp home page GithubHelp logo

rimraf's Introduction

The UNIX command rm -rf for node in a cross-platform implementation.

Install with npm install rimraf.

Major Changes

v4 to v5

  • There is no default export anymore. Import the functions directly using, e.g., import { rimrafSync } from 'rimraf'.

v3 to v4

  • The function returns a Promise instead of taking a callback.
  • Globbing requires the --glob CLI option or glob option property to be set. (Removed in 4.0 and 4.1, opt-in support added in 4.2.)
  • Functions take arrays of paths, as well as a single path.
  • Native implementation used by default when available, except on Windows, where this implementation is faster and more reliable.
  • New implementation on Windows, falling back to "move then remove" strategy when exponential backoff for EBUSY fails to resolve the situation.
  • Simplified implementation on POSIX, since the Windows affordances are not necessary there.
  • As of 4.3, return/resolve value is boolean instead of undefined.

API

Hybrid module, load either with import or require().

// 'rimraf' export is the one you probably want, but other
// strategies exported as well.
import { rimraf, rimrafSync, native, nativeSync } from 'rimraf'
// or
const { rimraf, rimrafSync, native, nativeSync } = require('rimraf')

All removal functions return a boolean indicating that all entries were successfully removed.

The only case in which this will not return true is if something was omitted from the removal via a filter option.

rimraf(f, [opts]) -> Promise

This first parameter is a path or array of paths. The second argument is an options object.

Options:

  • preserveRoot: If set to boolean false, then allow the recursive removal of the root directory. Otherwise, this is not allowed.

  • tmp: Windows only. Temp folder to place files and folders for the "move then remove" fallback. Must be on the same physical device as the path being deleted. Defaults to os.tmpdir() when that is on the same drive letter as the path being deleted, or ${drive}:\temp if present, or ${drive}:\ if not.

  • maxRetries: Windows and Native only. Maximum number of retry attempts in case of EBUSY, EMFILE, and ENFILE errors. Default 10 for Windows implementation, 0 for Native implementation.

  • backoff: Windows only. Rate of exponential backoff for async removal in case of EBUSY, EMFILE, and ENFILE errors. Should be a number greater than 1. Default 1.2

  • maxBackoff: Windows only. Maximum total backoff time in ms to attempt asynchronous retries in case of EBUSY, EMFILE, and ENFILE errors. Default 200. With the default 1.2 backoff rate, this results in 14 retries, with the final retry being delayed 33ms.

  • retryDelay: Native only. Time to wait between retries, using linear backoff. Default 100.

  • signal Pass in an AbortSignal to cancel the directory removal. This is useful when removing large folder structures, if you'd like to limit the time spent.

    Using a signal option prevents the use of Node's built-in fs.rm because that implementation does not support abort signals.

  • glob Boolean flag to treat path as glob pattern, or an object specifying glob options.

  • filter Method that returns a boolean indicating whether that path should be deleted. With async rimraf methods, this may return a Promise that resolves to a boolean. (Since Promises are truthy, returning a Promise from a sync filter is the same as just not filtering anything.)

    The first argument to the filter is the path string. The second argument is either a Dirent or Stats object for that path. (The first path explored will be a Stats, the rest will be Dirent.)

    If a filter method is provided, it will only remove entries if the filter returns (or resolves to) a truthy value. Omitting a directory will still allow its children to be removed, unless they are also filtered out, but any parents of a filtered entry will not be removed, since the directory will not be empty in that case.

    Using a filter method prevents the use of Node's built-in fs.rm because that implementation does not support filtering.

Any other options are provided to the native Node.js fs.rm implementation when that is used.

This will attempt to choose the best implementation, based on the Node.js version and process.platform. To force a specific implementation, use one of the other functions provided.

rimraf.sync(f, [opts])
rimraf.rimrafSync(f, [opts])

Synchronous form of rimraf()

Note that, unlike many file system operations, the synchronous form will typically be significantly slower than the async form, because recursive deletion is extremely parallelizable.

rimraf.native(f, [opts])

Uses the built-in fs.rm implementation that Node.js provides. This is used by default on Node.js versions greater than or equal to 14.14.0.

rimraf.native.sync(f, [opts])
rimraf.nativeSync(f, [opts])

Synchronous form of rimraf.native

rimraf.manual(f, [opts])

Use the JavaScript implementation appropriate for your operating system.

rimraf.manual.sync(f, [opts])
rimraf.manualSync(f, opts)

Synchronous form of rimraf.manual()

rimraf.windows(f, [opts])

JavaScript implementation of file removal appropriate for Windows platforms. Works around unlink and rmdir not being atomic operations, and EPERM when deleting files with certain permission modes.

First deletes all non-directory files within the tree, and then removes all directories, which should ideally be empty by that time. When an ENOTEMPTY is raised in the second pass, falls back to the rimraf.moveRemove strategy as needed.

rimraf.windows.sync(path, [opts])
rimraf.windowsSync(path, [opts])

Synchronous form of rimraf.windows()

rimraf.moveRemove(path, [opts])

Moves all files and folders to the parent directory of path with a temporary filename prior to attempting to remove them.

Note that, in cases where the operation fails, this may leave files lying around in the parent directory with names like .file-basename.txt.0.123412341. Until the Windows kernel provides a way to perform atomic unlink and rmdir operations, this is, unfortunately, unavoidable.

To move files to a different temporary directory other than the parent, provide opts.tmp. Note that this must be on the same physical device as the folder being deleted, or else the operation will fail.

This is the slowest strategy, but most reliable on Windows platforms. Used as a last-ditch fallback by rimraf.windows().

rimraf.moveRemove.sync(path, [opts])
rimraf.moveRemoveSync(path, [opts])

Synchronous form of rimraf.moveRemove()

Command Line Interface

rimraf version 4.3.0

Usage: rimraf <path> [<path> ...]
Deletes all files and folders at "path", recursively.

Options:
  --                   Treat all subsequent arguments as paths
  -h --help            Display this usage info
  --preserve-root      Do not remove '/' recursively (default)
  --no-preserve-root   Do not treat '/' specially
  -G --no-glob         Treat arguments as literal paths, not globs (default)
  -g --glob            Treat arguments as glob patterns
  -v --verbose         Be verbose when deleting files, showing them as
                       they are removed. Not compatible with --impl=native
  -V --no-verbose      Be silent when deleting files, showing nothing as
                       they are removed (default)
  -i --interactive     Ask for confirmation before deleting anything
                       Not compatible with --impl=native
  -I --no-interactive  Do not ask for confirmation before deleting

  --impl=<type>        Specify the implementation to use:
                       rimraf: choose the best option (default)
                       native: the built-in implementation in Node.js
                       manual: the platform-specific JS implementation
                       posix: the Posix JS implementation
                       windows: the Windows JS implementation (falls back to
                                move-remove on ENOTEMPTY)
                       move-remove: a slow reliable Windows fallback

Implementation-specific options:
  --tmp=<path>        Temp file folder for 'move-remove' implementation
  --max-retries=<n>   maxRetries for 'native' and 'windows' implementations
  --retry-delay=<n>   retryDelay for 'native' implementation, default 100
  --backoff=<n>       Exponential backoff factor for retries (default: 1.2)

mkdirp

If you need to create a directory recursively, check out mkdirp.

rimraf's People

Contributors

amilajack avatar aslushnikov avatar bcoe avatar cclauss avatar coderaiser avatar cowboy avatar dcroote avatar developingalex avatar forbeslindesay avatar isaacs avatar jkozera avatar josiasmontag avatar marr avatar mbtools avatar mikesprague avatar mmalecki avatar paulmillr avatar peterdavehello avatar quetzalcoatl avatar ritch avatar sashashura avatar shinnn avatar slhck avatar stevemao avatar tidyzq avatar tombyrer avatar unional avatar wvl avatar yosefd avatar zerok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rimraf's Issues

no default for maxBusyTries

If I don't pass the maxBusyTries option, I get:
uncaught: TypeError: Cannot read property 'maxBusyTries' of undefined

Making files/directories world writable (and readable) does matter

https://github.com/isaacs/rimraf/blob/master/rimraf.js

// make file writable
// user/group/world, doesn't matter at this point
// since it's about to get nuked.

If you make a large directory world writable, it will stay world writable for a significant period of time. At the very least this is an easy DOS. Another user account can create a file in it that the original process will be unable to remove.

Then, you don't just make the directory writable but also world readable. This is an easy information disclosure vulnerability.

Missing EPERM removing read-only files on windows

C:\>node -p "require('fs').unlink('minimatch/.git/objects/pack/pack-8b98e6c46b42
5c4dad6aa937a8a3300ba0e35785.idx',console.log)"
undefined
{ [Error: EPERM, unlink 'C:\minimatch\.git\objects\pack\pack-8b98e6c46b425c4dad6
aa937a8a3300ba0e35785.idx']
  errno: 50,
  code: 'EPERM',
  path: 'C:\\minimatch\\.git\\objects\\pack\\pack-8b98e6c46b425c4dad6aa937a8a330
0ba0e35785.idx' }

C:\>node -p "require('rimraf')('minimatch/.git/objects/pack/pack-8b98e6c46b425c4
dad6aa937a8a3300ba0e35785.idx',console.log)"
undefined
null

Using 'unlink' is not safe when running as 'root' as on Solaris 10

So, it turns out that this comment:

// Two possible strategies.
// 1. Assume it's a file.  unlink it, then do the dir stuff on EPERM or EISDIR
// 2. Assume it's a directory.  readdir, then do the file stuff on ENOTDIR
//
// Both result in an extra syscall when you guess wrong.  However, there
// are likely far more normal files in the world than directories.  This
// is based on the assumption that a the average number of files per
// directory is >= 1.
//
// If anyone ever complains about this, then I guess the strategy could
// be made configurable somehow.  But until then, YAGNI.

That I actually do need it.

I honestly can't believe I hit this, but I did. Basically, the issue is this:

On Solaris 10 (at least), if you run as root, it will let you call unlink on a directory and not return an error. This in turn makes any directory containing this undeletable, because the link count is now wrong.

The solution here is simple: either always use rmdir-readdir-unlink, or have an option to enable it in select cases.

The specific place I hit it was when using node-gyp and calling rebuild on a package, which did a clean, which in turn called rimraf.

I still can't believe this happened.

package.json does not validate

According to http://package-json-validator.com/, the package.json does not validate for this repo. npm (1.4.10) attempts to install rimraf and reports

npm ERR! Failed to parse json
npm ERR! Unexpected end of input
npm ERR! File: /Users/Joel/.npm/rimraf/2.2.8/package/package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file.

advertise it is way faster than `rm -rf`

I had that couple thousands of files to delete recursively inside a mapnik tile cache.
With rm -rf it takes hours. With rimraf it takes seconds.
There is something seriously wrong with rm...

Strange typo (unused code path?)

There seems to be a missing .code on rimraf.js line 98, so we always throw, even if er3.code === 'ENOENT'. Strangely though, if we were to add .code, then the stats.isDirectory() call following in line 102 could fail because stats could be undefined. So I'm not sure how to fix this code.

Thanks to @krisselden for noticing this.

NPM installation error

Hi,

I caught this error when I was trying to install:

issue

Is it possible to someone fix this? Thanks.

differing behavior between api and cli

given the following dir

foo
  /bar.txt
  /baz.txt

running cli command "rimraf foo/" removes all the files while keeping the fonts directory intact. However running the api command "rimraf('foo/', cb)" results in the files not being removed.

Install problem

Console output:

npm WARN package.json [email protected] No README data
npm http GET https://registry.npmjs.org/rimraf
npm http 304 https://registry.npmjs.org/rimraf
npm ERR! Error: UNKNOWN, symlink '../rimraf/bin.js'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Linux 2.6.32-358.el6.i686
npm ERR! command "node" "/usr/bin/npm" "install" "rimraf" "--save-dev"
npm ERR! cwd /srv/www/etools
npm ERR! node -v v0.10.18
npm ERR! npm -v 1.3.6
npm ERR! path ../rimraf/bin.js
npm ERR! code UNKNOWN
npm ERR! errno -1
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /srv/www/etools/npm-debug.log
npm ERR! not ok code 0

Contents of /srv/www/etools/npm-debug.log:

0 info it worked if it ends with ok
1 verbose cli [ 'node', '/usr/bin/npm', 'install', 'rimraf', '--save-dev' ]
2 info using [email protected]
3 info using [email protected]
4 warn package.json [email protected] No README data
5 verbose readDependencies using package.json deps
6 verbose cache add [ 'rimraf', null ]
7 verbose cache add name=undefined spec="rimraf" args=["rimraf",null]
8 verbose parsed url { protocol: null,
8 verbose parsed url   slashes: null,
8 verbose parsed url   auth: null,
8 verbose parsed url   host: null,
8 verbose parsed url   port: null,
8 verbose parsed url   hostname: null,
8 verbose parsed url   hash: null,
8 verbose parsed url   search: null,
8 verbose parsed url   query: null,
8 verbose parsed url   pathname: 'rimraf',
8 verbose parsed url   path: 'rimraf',
8 verbose parsed url   href: 'rimraf' }
9 silly lockFile d02b921e-rimraf rimraf
10 verbose lock rimraf /root/.npm/d02b921e-rimraf.lock
11 silly lockFile d02b921e-rimraf rimraf
12 silly lockFile d02b921e-rimraf rimraf
13 verbose addNamed [ 'rimraf', '' ]
14 verbose addNamed [ null, '*' ]
15 silly lockFile 30545280-rimraf rimraf@
16 verbose lock rimraf@ /root/.npm/30545280-rimraf.lock
17 silly addNameRange { name: 'rimraf', range: '*', hasData: false }
18 verbose url raw rimraf
19 verbose url resolving [ 'https://registry.npmjs.org/', './rimraf' ]
20 verbose url resolved https://registry.npmjs.org/rimraf
21 info trying registry request attempt 1 at 06:38:59
22 verbose etag "28422P7L4LQIK6Z2ACFSWPTFI"
23 http GET https://registry.npmjs.org/rimraf
24 http 304 https://registry.npmjs.org/rimraf
25 silly registry.get cb [ 304,
25 silly registry.get   { server: 'CouchDB/1.3.1 (Erlang OTP/R15B03)',
25 silly registry.get     etag: '"28422P7L4LQIK6Z2ACFSWPTFI"',
25 silly registry.get     date: 'Tue, 10 Dec 2013 06:38:43 GMT',
25 silly registry.get     'content-length': '0' } ]
26 verbose etag rimraf from cache
27 silly addNameRange number 2 { name: 'rimraf', range: '*', hasData: true }
28 silly addNameRange versions [ 'rimraf',
28 silly addNameRange   [ '1.0.0',
28 silly addNameRange     '1.0.1',
28 silly addNameRange     '1.0.2',
28 silly addNameRange     '1.0.4',
28 silly addNameRange     '1.0.5',
28 silly addNameRange     '1.0.6',
28 silly addNameRange     '1.0.7',
28 silly addNameRange     '1.0.8',
28 silly addNameRange     '1.0.9',
28 silly addNameRange     '2.0.0',
28 silly addNameRange     '2.0.1',
28 silly addNameRange     '2.0.2',
28 silly addNameRange     '2.0.3',
28 silly addNameRange     '2.1.0',
28 silly addNameRange     '2.1.1',
28 silly addNameRange     '2.1.2',
28 silly addNameRange     '2.1.3',
28 silly addNameRange     '2.1.4',
28 silly addNameRange     '2.2.0',
28 silly addNameRange     '2.2.1',
28 silly addNameRange     '2.2.2',
28 silly addNameRange     '2.2.3',
28 silly addNameRange     '2.2.4',
28 silly addNameRange     '2.2.5' ] ]
29 verbose addNamed [ 'rimraf', '2.2.5' ]
30 verbose addNamed [ '2.2.5', '2.2.5' ]
31 silly lockFile 26564256-rimraf-2-2-5 [email protected]
32 verbose lock [email protected] /root/.npm/26564256-rimraf-2-2-5.lock
33 silly lockFile 26564256-rimraf-2-2-5 [email protected]
34 silly lockFile 26564256-rimraf-2-2-5 [email protected]
35 silly lockFile 30545280-rimraf rimraf@
36 silly lockFile 30545280-rimraf rimraf@
37 silly resolved [ { name: 'rimraf',
37 silly resolved     version: '2.2.5',
37 silly resolved     main: 'rimraf.js',
37 silly resolved     description: 'A deep deletion module for node (like `rm -rf`)',
37 silly resolved     author:
37 silly resolved      { name: 'Isaac Z. Schlueter',
37 silly resolved        email: '[email protected]',
37 silly resolved        url: 'http://blog.izs.me/' },
37 silly resolved     license:
37 silly resolved      { type: 'MIT',
37 silly resolved        url: 'https://github.com/isaacs/rimraf/raw/master/LICENSE' },
37 silly resolved     repository: { type: 'git', url: 'git://github.com/isaacs/rimraf.git' },
37 silly resolved     scripts: { test: 'cd test && bash run.sh' },
37 silly resolved     bin: { rimraf: './bin.js' },
37 silly resolved     contributors: [ [Object], [Object], [Object], [Object], [Object] ],
37 silly resolved     readme: '`rm -rf` for node.\n\nInstall with `npm install rimraf`, or just drop rimraf.js somewhere.\n\n## API\n\n`rimraf(f, callback)`\n\nThe callback will be called with an error if there is one.  Certain\nerrors are handled for you:\n\n* Windows: `EBUSY` and `ENOTEMPTY` - rimraf will back off a maximum of\n  `opts.maxBusyTries` times before giving up.\n* `ENOENT` - If the file doesn\'t exist, rimraf will return\n  successfully, since your desired outcome is already the case.\n\n## rimraf.sync\n\nIt can remove stuff synchronously, too.  But that\'s not so good.  Use\nthe async API.  It\'s better.\n\n## CLI\n\nIf installed with `npm install rimraf -g` it can be used as a global\ncommand `rimraf <path>` which is useful for cross platform support.\n\n## mkdirp\n\nIf you need to create a directory recursively, check out\n[mkdirp](https://github.com/substack/node-mkdirp).\n',
37 silly resolved     readmeFilename: 'README.md',
37 silly resolved     bugs: { url: 'https://github.com/isaacs/rimraf/issues' },
37 silly resolved     _id: '[email protected]',
37 silly resolved     _from: 'rimraf@' } ]
38 info install [email protected] into /srv/www/etools
39 info installOne [email protected]
40 info /srv/www/etools/node_modules/rimraf unbuild
41 verbose tar unpack /root/.npm/rimraf/2.2.5/package.tgz
42 silly lockFile 9d91d4b1-v-www-etools-node-modules-rimraf tar:///srv/www/etools/node_modules/rimraf
43 verbose lock tar:///srv/www/etools/node_modules/rimraf /root/.npm/9d91d4b1-v-www-etools-node-modules-rimraf.lock
44 silly lockFile d079219e-oot-npm-rimraf-2-2-5-package-tgz tar:///root/.npm/rimraf/2.2.5/package.tgz
45 verbose lock tar:///root/.npm/rimraf/2.2.5/package.tgz /root/.npm/d079219e-oot-npm-rimraf-2-2-5-package-tgz.lock
46 silly gunzTarPerm modes [ '755', '644' ]
47 silly gunzTarPerm extractEntry package.json
48 silly gunzTarPerm extractEntry README.md
49 silly gunzTarPerm extractEntry LICENSE
50 silly gunzTarPerm extractEntry bin.js
51 silly gunzTarPerm extractEntry rimraf.js
52 silly gunzTarPerm extractEntry AUTHORS
53 silly gunzTarPerm extractEntry test/test-async.js
54 silly gunzTarPerm extractEntry test/test-sync.js
55 silly gunzTarPerm extractEntry test/run.sh
56 silly gunzTarPerm extractEntry test/setup.sh
57 silly lockFile 9d91d4b1-v-www-etools-node-modules-rimraf tar:///srv/www/etools/node_modules/rimraf
58 silly lockFile 9d91d4b1-v-www-etools-node-modules-rimraf tar:///srv/www/etools/node_modules/rimraf
59 silly lockFile d079219e-oot-npm-rimraf-2-2-5-package-tgz tar:///root/.npm/rimraf/2.2.5/package.tgz
60 silly lockFile d079219e-oot-npm-rimraf-2-2-5-package-tgz tar:///root/.npm/rimraf/2.2.5/package.tgz
61 info preinstall [email protected]
62 verbose readDependencies using package.json deps
63 verbose readDependencies using package.json deps
64 silly resolved []
65 verbose about to build /srv/www/etools/node_modules/rimraf
66 info build /srv/www/etools/node_modules/rimraf
67 verbose linkStuff [ false, false, false, '/srv/www/etools/node_modules' ]
68 info linkStuff [email protected]
69 verbose linkBins [email protected]
70 verbose link bins [ { rimraf: './bin.js' },
70 verbose link bins   '/srv/www/etools/node_modules/.bin',
70 verbose link bins   false ]
71 verbose linkMans [email protected]
72 verbose rebuildBundles [email protected]
73 info /srv/www/etools/node_modules/rimraf unbuild
74 info preuninstall [email protected]
75 info uninstall [email protected]
76 verbose true,/srv/www/etools/node_modules,/srv/www/etools/node_modules unbuild [email protected]
77 verbose /srv/www/etools/node_modules/.bin,[object Object] binRoot
78 info postuninstall [email protected]
79 error Error: UNKNOWN, symlink '../rimraf/bin.js'
80 error If you need help, you may report this log at:
80 error     <http://github.com/isaacs/npm/issues>
80 error or email it to:
80 error     <[email protected]>
81 error System Linux 2.6.32-358.el6.i686
82 error command "node" "/usr/bin/npm" "install" "rimraf" "--save-dev"
83 error cwd /srv/www/etools
84 error node -v v0.10.18
85 error npm -v 1.3.6
86 error path ../rimraf/bin.js
87 error code UNKNOWN
88 error errno -1
89 verbose exit [ -1, true ]

Awesome tool!

This tool saves my time, I really like this! Congrats for the awesome work.

You have a tip for copy tool?

Error parsing the package.json file when running 'yo webapp'

The strange thing is that I don't see any changes on the history for this file between yesterday morning and now (I'm in France BTW - consider time zone differences), although I wrote an app yesterday calling 'yo webapp', and I did not experience this issue.

0 info it worked if it ends with ok
1 verbose cli [ 'node', '/usr/local/bin/npm', 'install', 'rimraf' ]
2 info using [email protected]
3 info using [email protected]
4 verbose cache add [ 'rimraf', null ]
5 verbose cache add name=undefined spec="rimraf" args=["rimraf",null]
6 verbose parsed url { protocol: null,
6 verbose parsed url slashes: null,
6 verbose parsed url auth: null,
6 verbose parsed url host: null,
6 verbose parsed url port: null,
6 verbose parsed url hostname: null,
6 verbose parsed url hash: null,
6 verbose parsed url search: null,
6 verbose parsed url query: null,
6 verbose parsed url pathname: 'rimraf',
6 verbose parsed url path: 'rimraf',
6 verbose parsed url href: 'rimraf' }
7 silly lockFile d02b921e-rimraf rimraf
8 verbose lock rimraf /Users/boostup/.npm/d02b921e-rimraf.lock
9 silly lockFile d02b921e-rimraf rimraf
10 silly lockFile d02b921e-rimraf rimraf
11 verbose addNamed [ 'rimraf', '' ]
12 verbose addNamed [ null, '' ]
13 silly lockFile 30545280-rimraf rimraf@
14 verbose lock rimraf@ /Users/boostup/.npm/30545280-rimraf.lock
15 silly addNameRange { name: 'rimraf', range: '
', hasData: false }
16 verbose url raw rimraf
17 verbose url resolving [ 'https://registry.npmjs.org/', './rimraf' ]
18 verbose url resolved https://registry.npmjs.org/rimraf
19 info trying registry request attempt 1 at 15:27:11
20 verbose etag "CQHWPTC3KAPIU8K8Z8GLW2G8O"
21 http GET https://registry.npmjs.org/rimraf
22 http 304 https://registry.npmjs.org/rimraf
23 silly registry.get cb [ 304,
23 silly registry.get { date: 'Mon, 19 May 2014 13:27:13 GMT',
23 silly registry.get server: 'Apache',
23 silly registry.get via: '1.1 varnish',
23 silly registry.get 'last-modified': 'Mon, 19 May 2014 13:27:13 GMT',
23 silly registry.get 'cache-control': 'max-age=1',
23 silly registry.get etag: '"CQHWPTC3KAPIU8K8Z8GLW2G8O"',
23 silly registry.get 'x-served-by': 'cache-lcy1123-LCY',
23 silly registry.get 'x-cache': 'HIT',
23 silly registry.get 'x-cache-hits': '1',
23 silly registry.get 'x-timer': 'S1400506033.064686298,VS0,VE171',
23 silly registry.get vary: 'Accept',
23 silly registry.get 'content-length': '0',
23 silly registry.get 'keep-alive': 'timeout=10, max=50',
23 silly registry.get connection: 'Keep-Alive' } ]
24 verbose etag rimraf from cache
25 silly addNameRange number 2 { name: 'rimraf', range: '*', hasData: true }
26 silly addNameRange versions [ 'rimraf',
26 silly addNameRange [ '1.0.0',
26 silly addNameRange '1.0.1',
26 silly addNameRange '1.0.2',
26 silly addNameRange '1.0.4',
26 silly addNameRange '1.0.5',
26 silly addNameRange '1.0.6',
26 silly addNameRange '1.0.7',
26 silly addNameRange '1.0.8',
26 silly addNameRange '1.0.9',
26 silly addNameRange '2.0.0',
26 silly addNameRange '2.0.1',
26 silly addNameRange '2.0.2',
26 silly addNameRange '2.0.3',
26 silly addNameRange '2.1.0',
26 silly addNameRange '2.1.1',
26 silly addNameRange '2.1.2',
26 silly addNameRange '2.1.3',
26 silly addNameRange '2.1.4',
26 silly addNameRange '2.2.0',
26 silly addNameRange '2.2.1',
26 silly addNameRange '2.2.2',
26 silly addNameRange '2.2.3',
26 silly addNameRange '2.2.4',
26 silly addNameRange '2.2.5',
26 silly addNameRange '2.2.6',
26 silly addNameRange '2.2.8' ] ]
27 verbose addNamed [ 'rimraf', '2.2.8' ]
28 verbose addNamed [ '2.2.8', '2.2.8' ]
29 silly lockFile b87241a4-rimraf-2-2-8 [email protected]
30 verbose lock [email protected] /Users/boostup/.npm/b87241a4-rimraf-2-2-8.lock
31 silly lockFile b87241a4-rimraf-2-2-8 [email protected]
32 silly lockFile b87241a4-rimraf-2-2-8 [email protected]
33 silly lockFile 30545280-rimraf rimraf@
34 silly lockFile 30545280-rimraf rimraf@
35 error Failed to parse json
35 error Unexpected end of input
36 error File: /Users/boostup/.npm/rimraf/2.2.8/package/package.json
37 error Failed to parse package.json data.
37 error package.json must be actual JSON, not just JavaScript.
37 error
37 error This is not a bug in npm.
37 error Tell the package author to fix their package.json file. JSON.parse
38 error System Darwin 13.1.0
39 error command "node" "/usr/local/bin/npm" "install" "rimraf"
40 error cwd /Users/boostup/Documents/CaptivePortalTest
41 error node -v v0.10.28
42 error npm -v 1.4.9
43 error file /Users/boostup/.npm/rimraf/2.2.8/package/package.json
44 error code EJSONPARSE
45 verbose exit [ 1, true ]

EISDIR when unlinking with 2.1.0

Hi, just tried the latest 2.1.0 release, I use rimraf to cleanup the cache folder, containing other folders but it fails now:

Unable to start server due to error: EISDIR, unlink '/---/cache/p_7641'
Trace
    at ----
    at CB (/srv/node/staging/node_modules/rimraf/rimraf.js:46:5)
    at /srv/node/staging/node_modules/rimraf/rimraf.js:67:12
    at Object.oncomplete (fs.js:297:15)

Thanks.

rimraf.js:113 options not given

Would it be like this?

function fixWinEPERMSync (p, options, er, cb) {
  try {
    options.chmodSync(p, 666)
  } catch (er2) {
    if (er2.code === "ENOENT")
      return
    else
      throw er
  }

EPERM issue

I have faced EPERM on executing grunt-contrib-clean. I think some latest changes causes this.

And I working working on windows7, grunt - 0.4.4

This is error, I am getting in my console.

Warning: Unable to delete "HILAR" file (EPERM, operation not permitted 'D:\..\HILAR'). Use --force to continue.

Error when deleting .git folder in windows

This issue only happens in windows when using rimraf 2.1.x. When using 2.0.x it works fine.
When rimraf is used to delete a git repository, it fails when removing .git/objects/pack/*.idx and *.pack files.

I've spotted this issue because I've upgraded rimraf in 0.8.x release of http://github.com/twitter/bower and windows users started to complain. After some debugging, the unlink of these files error out with EPERM. Then rimraf interprets them as a directory and some other error happens. I think this is related to the fact the older versions of rimraf tried to make the file writable before deleting it.
When I tested, I had no hanging process on those files or the .git folder.

To reproduce:
$ git clone git://github.com/satazor/SparkMD5.git

var rimraf = require('rimraf');

rimraf('SparkMD5', function (err) {
  console.log(err);
});

2.3.2 regression

This patch introduced following error in our application:

$ ember test
version: 0.1.15
Could not find watchman, falling back to NodeWatcher for file system events
Cleanup error.
undefined is not a function
TypeError: undefined is not a function
    at Function.rimrafSync (***/node_modules/ember-cli/node_modules/broccoli-caching-writer/node_modules/rimraf/rimraf.js:262:13)
    at ConfigLoader.CachingWriter.cleanup (***/node_modules/ember-cli/node_modules/broccoli-caching-writer/index.js:114:10)
    at cleanupTree (***/node_modules/ember-cli/node_modules/broccoli/lib/builder.js:128:19)
    at ***/node_modules/ember-cli/node_modules/promise-map-series/index.js:11:14
    at lib$rsvp$$internal$$tryCatch (***/node_modules/ember-cli/node_modules/promise-map-series/node_modules/rsvp/dist/rsvp.js:489:16)
    at lib$rsvp$$internal$$invokeCallback ***/node_modules/ember-cli/node_modules/promise-map-series/node_modules/rsvp/dist/rsvp.js:501:17)
    at lib$rsvp$$internal$$publish ***/node_modules/ember-cli/node_modules/promise-map-series/node_modules/rsvp/dist/rsvp.js:472:11)
    at lib$rsvp$asap$$flush (***/node_modules/ember-cli/node_modules/promise-map-series/node_modules/rsvp/dist/rsvp.js:1290:9)
    at process._tickCallback (node.js:355:11)
Build failed.

With version 2.3.1, everything works.

2.3.1 does not exit for hours if file can't be deleted in directory with hypens

This is fixed in 2.3.2 by 4ddd0b2. I wasn't sure whether I should even open this issue because it's fixed, but I thought it might help other people who run into this.

On Windows, if there's a file that can't be deleted in a deep directory with hypens, [email protected] will not return for hours. For example, if package.json can't be deleted in:

example\node_modules\sqlite3\node_modules\node-pre-gyp\node_modules\tar-pack\node_modules\readable-stream\node_modules\core-util-is\package.json

This is easy to reproduce by creating this folder and removing the 'delete' permission on package.json. I doubt it's useful anymore, but I made a script that can reproduce this. Run repro setup to create the un-deletable file, node . to run rimraf, and repro cleanup to delete it.

Allow passing `fs` in as an argument

It would be nice if rimraf could be called as

rimraf(fs, location, callback)

rimraf should also support rimraf(location, callback) which defaults the fs interface to require('fs')

If this sounds like a reasonable idea, I'll open a pull request.

Motivation

  • allows rimraf to work on any file system as long as it implements the fs interface. Think remote file systems specs that implement the fs interface. Think browser file systems that implement the fs interface.
  • allows you to unit test any file system related code by passing in a memory backed file system api.

Failed to parse package.json data.

trying to install bower on an ubuntu remote server, I got an error about the package.json file of rimraf. I tried to install rimraf directly according to instructions in your readme but I got the same error, reproduced below for your convenience

npm http GET https://registry.npmjs.org/rimraf
npm http 304 https://registry.npmjs.org/rimraf
npm ERR! Failed to parse json
npm ERR! Unexpected end of input
npm ERR! File: /home/michael/.npm/rimraf/2.2.2/package/package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse

npm ERR! System Linux 3.8.0-19-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "rimraf"
npm ERR! cwd /home/michael
npm ERR! node -v v0.10.22
npm ERR! npm -v 1.3.14
npm ERR! file /home/michael/.npm/rimraf/2.2.2/package/package.json
npm ERR! code EJSONPARSE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/michael/npm-debug.log
npm ERR! not ok code 0

'glob' has no method 'hasMagic' error in v2.3.2

Woke up to a broken build and tracked it down to v2.3.2, probably 4ddd0b2. I have not submitted a PR because I don't have time at the moment, but will start if I'm not beaten to it. Probably can't until later today or tomorrow.

rimraf is used by broccoli-caching-writer, which is used by ember-cli, which is why I was affected by this by the way. Anybody who did not peg their rimraf version < 2.3.2 and is using ember-cli is probably experiencing this too.

TypeError: Object function glob(pattern, options, cb) {
  if (typeof options === "function") cb = options, options = {}
  if (!options) options = {}

  if (typeof options === "number") {
    deprecated()
    return
  }

  var g = new Glob(pattern, options, cb)
  return g.sync ? g.found : g
} has no method 'hasMagic'
    at Function.rimrafSync [as sync] (/.../node_modules/rimraf/rimraf.js:262:13)
    ...

Windows support (ENOTEMPTY issues)

I'd like to re-open the discussion about ENOTEMPTY problems on Windows, as previously raised in #25.

Technical background: On Windows, a file can be "busy" when our process or another process still has an open file handle. This can happen unpredictably; e.g. a webserver might have an open connection serving the file, or a virus scanner might be accessing it. When you remove a busy file (with fs.unlinkSync or fs.unlink), unlinkSync will return successfully, but the file sticks around on the file system until the handle is released. As a result, when rimraf removes a file and then tries to rmdir the containing directory, the rmdir operation can fail with ENOTEMPTY. (This is from memory and hearsay, so some details may be wrong!)

This causes random sporadic failures - see e.g. the stack trace reported in broccolijs/broccoli#232.

There is currently a workaround implemented in rimraf (d819b12, fixing #25). However, it is based on retrying repeatedly with setTimeout, and it only works in the asynchronous version. Of course, this seems pretty hackish and potentially unreliable. We're using rimraf a lot in the Broccoli plugin ecosystem, and it makes me worried that we'll have lots of issues on Windows down the line.

So I'd love it if we could find a proper fix for this issue, rather than working around it.

It surely must be possible to find a fix - and this is why I'm opening this issue again: For example, commands like rmdir /s can't possibly be relying on weird workarounds, can they? And Windows Explorer lets you delete directories, without random (flickering) failures stemming from your virus scanner accessing some file.

More detail for people wishing to dig in: this gist by @stefanpenner; this comment in libuv's fs.c; libuv's unlink implementation on Windows. I wonder if libuv's very roundabout unlink implementation (presumably to mimic POSIX) might be a contributor. Could this be fixable in libuv, or could we come up with a platform-specific C implementation for rimraf on Windows that doesn't use libuv?

Failed to parse package.json data.

trying to install bower on an ubuntu remote server, I got an error about the package.json file of rimraf. I tried to install rimraf directly according to instructions in your readme but I got the same error, reproduced below for your convenience

npm http GET https://registry.npmjs.org/rimraf
npm http 304 https://registry.npmjs.org/rimraf
npm ERR! Failed to parse json
npm ERR! Unexpected end of input
npm ERR! File: /home/michael/.npm/rimraf/2.2.2/package/package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse

npm ERR! System Linux 3.8.0-19-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "rimraf"
npm ERR! cwd /home/michael
npm ERR! node -v v0.10.22
npm ERR! npm -v 1.3.14
npm ERR! file /home/michael/.npm/rimraf/2.2.2/package/package.json
npm ERR! code EJSONPARSE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/michael/npm-debug.log
npm ERR! not ok code 0

Failed to parse package.json data.

trying to install bower on an ubuntu remote server, I got an error about the package.json file of rimraf. I tried to install rimraf directly according to instructions in your readme but I got the same error, reproduced below for your convenience

npm http GET https://registry.npmjs.org/rimraf
npm http 304 https://registry.npmjs.org/rimraf
npm ERR! Failed to parse json
npm ERR! Unexpected end of input
npm ERR! File: /home/michael/.npm/rimraf/2.2.2/package/package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse

npm ERR! System Linux 3.8.0-19-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "rimraf"
npm ERR! cwd /home/michael
npm ERR! node -v v0.10.22
npm ERR! npm -v 1.3.14
npm ERR! file /home/michael/.npm/rimraf/2.2.2/package/package.json
npm ERR! code EJSONPARSE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/michael/npm-debug.log
npm ERR! not ok code 0

Rimraf chokes on AFS volumes (ENOTEMPTY throttling)

The current strategy of trying to rmdir first and only using readdir on ENOTEMPTY (see

// try to rmdir first, and only readdir on ENOTEMPTY or EEXIST (SunOS)
) chokes badly when used on AFS volumes.

By default, it seems AFS fileservers will throttle single clients that make more than 10 failed RPCs in a row by delaying a full 3 seconds (to protect the server from poorly-written clients). Unsurprisingly, this slows rimraf to a crawl, with fairly wide implications for Node projects on AFS volumes given rimraf's popularity. As an example, here's part of an strace log from npm uninstall on my machine (note the timestamps...):

...
18327 17:00:52 rmdir("/path/to/home/myproject/node_modules/gobble/node_modules/minimatch" <unfinished ...>
18318 17:00:52 read(8, "\1\0\0\0\0\0\0\0", 1024) = 8
18318 17:00:52 epoll_wait(5,  <unfinished ...>
18325 17:00:55 <... rmdir resumed> )    = -1 ENOTEMPTY (Directory not empty)
18325 17:00:55 write(8, "\1\0\0\0\0\0\0\0", 8) = 8
18325 17:00:55 rmdir("/path/to/home/myproject/node_modules/gobble/node_modules/mkdirp" <unfinished ...>
18318 17:00:55 <... epoll_wait resumed> {{EPOLLIN, {u32=8, u64=8}}}, 1024, -1) = 1
18318 17:00:55 read(8, "\1\0\0\0\0\0\0\0", 1024) = 8
18318 17:00:55 epoll_wait(5,  <unfinished ...>
18328 17:00:58 <... rmdir resumed> )    = -1 ENOTEMPTY (Directory not empty)
18328 17:00:58 write(8, "\1\0\0\0\0\0\0\0", 8) = 8
18318 17:00:58 <... epoll_wait resumed> {{EPOLLIN, {u32=8, u64=8}}}, 1024, -1) = 1
18328 17:00:58 rmdir("/path/to/home/myproject/node_modules/gobble/node_modules/promise-map-series" <unfinished ...>
18318 17:00:58 read(8, "\1\0\0\0\0\0\0\0", 1024) = 8
18318 17:00:58 epoll_wait(5,  <unfinished ...>
18326 17:01:01 <... rmdir resumed> )    = -1 ENOTEMPTY (Directory not empty)
18326 17:01:01 write(8, "\1\0\0\0\0\0\0\0", 8) = 8
18318 17:01:01 <... epoll_wait resumed> {{EPOLLIN, {u32=8, u64=8}}}, 1024, -1) = 1
...

Of course, it would be ideal if the OS itself could deal with this and not hit the server for each of those requests as is already done for some commands like mkdir -- see http://milek.blogspot.com/2014/01/mkdir-performance.html -- though I'm not familiar enough with the ins and outs of filesystems to know if it's possible to do that for rmdir.

Thoughts?

error building ember addon

steps to reproduce:
-git clone https://github.com/indexiatech/ember-idx-tree.git
-npm install
-bower install
-ember server

TypeError: Object function glob(pattern, options, cb) {
  if (typeof options === "function") cb = options, options = {}
  if (!options) options = {}

  if (typeof options === "number") {
    deprecated()
    return
  }

  var g = new Glob(pattern, options, cb)
  return g.sync ? g.found : g
} has no method 'hasMagic'
at Function.rimrafSync [as sync] (/home/deefactorial/git/ember-idx-tree/node_modules/ember-cli/node_modules/broccoli-caching-writer/node_modules/rimraf/rimraf.js:262:13)

looks like a es6-shim issue in the rimraf node module

"sync" method fails when no directory found

Hi, Issacs ...

Yup .. like the title says ...

the sync method throw errors when no directory found ... but async method works fine ... take a look ...

usage:

rimraf.sync('build'); // no directory exists

out:

Error: ENOENT, No such file or directory 'build'
    at Object.lstatSync (fs.js:397:18)
    at Function.rimrafSync [as sync] (/Users/outaTiME/Development/projects/node_modules/rimraf/rimraf.js:134:23)
    at [object Object].action (/Users/outaTiME/Development/projects/skycop/skyweb-mvc/Jakefile:33:12)
    at [object Object].runNextTask (/opt/node/lib/node_modules/jake/lib/jake.js:351:27)
    at [object Object].runTask (/opt/node/lib/node_modules/jake/lib/jake.js:196:10)
    at Object.<anonymous> (/opt/node/lib/node_modules/jake/bin/cli.js:73:10)
    at Module._compile (module.js:432:26)
    at Object..js (module.js:450:10)
    at Module.load (module.js:351:31)
    at Function._load (module.js:310:12)

otherwise ... the non sync method works fine ...

usage:

rimraf('build', function() {
  console.log('coool!');
});

my simple workaround was ... surround sync method with "exists" check ^^

thks !

Returns undefined instead of error when dir does not exist

Fails on:

  • OSX 10.9, Node 0.10.22
  • Win 8.1, Node 8.22

rimraf = require('rimraf');

rimraf('./rimraftest', function(err) {
console.log(err);
})

//if directory ./rimraftest exists err = null
//if directory ./rimraftest does not exist err = undefined

i.e. this doesn't work well
rimraf('./rimraftest', function(err) {
if(err) console.log(err);
})

rimraf doesn't work

I installed "rimraf" from npm and tested it, but it just does nothing. Nothing heppens after rimraf command. What am I doing wrong?

OS Win7x64
node -v v0.12.0
npm -v 2.5.1

Z:\test_folder>

Z:\test_folder>rimraf Z:\test_folder

Z:\test_folder>rimraf "Z:\test_folder"

Z:\test_folder>rimraf "Z:\test_folder\"

Z:\test_folder>rimraf Z:\test_folder\

Z:\test_folder>

Doesn't work

fs.js:456
  return binding.rmdir(pathModule._makeLong(path));
                 ^
Error: ENOTEMPTY, directory not empty 'c:\work\modules\raptor-gold\build\temp'
    at Object.fs.rmdirSync (fs.js:456:18)
    at Function.rimrafSync [as sync] (c:\work\modules\raptor-gold\node_modules\rimraf\rimraf.js:128:12)
    at Object.build (c:\work\modules\raptor-gold\build\raptor-builder.js:77:12)
    at Object.<anonymous> (c:\work\modules\raptor-gold\build\build.js:5:9)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.runMain (module.js:492:10)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)

Quick question

What happens if rimraf accidentally gets called with an undefined value as parameter?
I hope it's not going to perform an rm -rf for the root directory or for the current working directory. Can you please confirm? Thanks!

it uses graceful-fs which monkey-patches fs

This may be an npm user error, but perhaps it's worth mentioning in the README.

graceful-fs is an optional dependency which I don't want to install, but it gets installed whenever I depend on rimraf. How do I make it not do that?

Would you accept a PR for 'empty' mode?

I've had a few cases where I've needed to empty a directory, ie delete everything inside it (including subdirs) but leave the main directory alone.

The reason I need to do this (rather than just rimraf the whole dir and then recreate it) is I have a Gaze instance watching the directory, and I want it to continue watching uninterrupted while the dir is emptied and then refilled.

So ideally I'd like rimraf to accept an optional 2nd argument before the callback, like this: rimraf('./foo', true, callback);

Or alternatively: rimraf('./foo', {empty: true}, callback);

Would you accept a PR for that?

`[email protected]` does not play well with `es6-shim`

It looks like glob or minimatch is doing something clever that's causing it to interpret a directory or file name with [stuff] as character classes when used with the es6-shim version of the RegExp constructor, which doesn't go so well for everybody:

not ok test/unpack.js ................................... 0/1
    Command: "/usr/local/bin/iojs unpack.js"
    TAP version 13
    not ok 1 test/unpack.js
      ---
        exit:    1
        stderr:  |
          /Users/ogd/Documents/projects/packard/node_modules/es6-shim/es6-shim.js:1342
                return new OrigRegExp(pattern, flags);
                       ^
          SyntaxError: Invalid regular expression: /^(?!\.)(?=.)[2012-01-20] undefined$/: Range out of order in character class
              at RegExp (native)
              at new RegExp (/Users/ogd/Documents/projects/packard/node_modules/es6-shim/es6-shim.js:1342:14)
              at Minimatch.parse (/Users/ogd/Documents/projects/packard/node_modules/glob/node_modules/minimatch/minimatch.js:553:16)
              at Array.map (native)
              at Minimatch.<anonymous> (/Users/ogd/Documents/projects/packard/node_modules/glob/node_modules/minimatch/minimatch.js:173:14)
              at Array.map (native)
              at Minimatch.make (/Users/ogd/Documents/projects/packard/node_modules/glob/node_modules/minimatch/minimatch.js:172:13)
              at new Minimatch (/Users/ogd/Documents/projects/packard/node_modules/glob/node_modules/minimatch/minimatch.js:127:8)
              at setopts (/Users/ogd/Documents/projects/packard/node_modules/glob/common.js:123:20)
              at new Glob (/Users/ogd/Documents/projects/packard/node_modules/glob/glob.js:116:3)
              at glob (/Users/ogd/Documents/projects/packard/node_modules/glob/glob.js:73:10)
              at rimraf (/Users/ogd/Documents/projects/packard/node_modules/rimraf/rimraf.js:57:3)
              at /Users/ogd/Documents/projects/packard/node_modules/rimraf/rimraf.js:230:7
              at Array.forEach (native)
              at /Users/ogd/Documents/projects/packard/node_modules/rimraf/rimraf.js:229:11
              at FSReqWrap.oncomplete (fs.js:77:15)
        command: "/usr/local/bin/iojs unpack.js"
      ...

    1..1
    # tests 1
    # fail  1

callback called before directory is really deleted

rimraf = require "rimraf"
fs = require "fs"

dir = "test"

fs.mkdirSync dir

rimraf dir, ->
    fs.mkdir dir
    ###
    Error: EEXIST, file already exists 'test'
        at Object.fs.mkdirSync (fs.js:483:18)
        at Object.<anonymous> (/Users/vyacheslav/test.coffee:10:6)
        at Object.<anonymous> (/Users/vyacheslav/test.coffee:29:4)
        at Module._compile (module.js:449:26)
        at Object.exports.run (/usr/local/share/npm/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:82:25)
        at compileScript (/usr/local/share/npm/lib/node_modules/coffee-script/lib/coffee-script/command.js:177:29)
        at fs.stat.notSources.(anonymous function) (/usr/local/share/npm/lib/node_modules/coffee-script/lib/coffee-script/command.js:152:18)
        at fs.readFile (fs.js:176:14)
        at Object.oncomplete (fs.js:297:15)
    ###

Assertion Error

Trying to use with gulp and running this command:

gulp
.task('clean:bower', function() {
  rimraf(paths.clean.bower);
})

and it returns the following error:

AssertionError: "undefined" == true
    at Object.rimraf [as rm] (C:\web\www\node_modules\rimraf\rimraf.js:37:3)
    at Gulp.gulp.task.task.task.task.gulp.src.cwd (C:\web\www\gxl-boilerplate-jq\.build\tasks\clean.js:10:12)
    at module.exports (C:\web\www\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:34:7)
    at Gulp.Orchestrator._runTask (C:\web\www\node_modules\gulp\node_modules\orchestrator\index.js:273:3)
    at Gulp.Orchestrator._runStep (C:\web\www\node_modules\gulp\node_modules\orchestrator\index.js:214:10)
    at Gulp.Orchestrator.start (C:\web\www\node_modules\gulp\node_modules\orchestrator\index.js:134:8)
    at C:\Users\E022145\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:129:20
    at process._tickCallback (node.js:419:13)
    at Function.Module.runMain (module.js:499:11)
    at startup (node.js:119:16)

disregard, was missing callback

Return dir path in cb in addition to the error

I know I can just do

var dir = 'path';
rimraf(dir, function(err) {
  mkdirp(dir); 
});

but it would be nice if i didnt have to declare var dir='path'; first and it gave it to me automatically:

rimraf('path', function(err, dir) {
  mkdirp(dir); 
});

no default for maxBusyTries

If I don't pass the maxBusyTries option, I get:
uncaught: TypeError: Cannot read property 'maxBusyTries' of undefined

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.