Created
March 20, 2016 12:28
-
-
Save chuck0523/600de476b641ddc4dc5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs') | |
var rimraf = require('rimraf') | |
function fsRemoveEmptyDir() { | |
fs.mkdirSync('foo') | |
fs.rmdirSync('foo') | |
// 成功する。 | |
} | |
function rimrafRemoveEmptyDir() { | |
fs.mkdirSync('foo') | |
rimraf('foo', function(error){}) | |
// 成功する。 | |
} | |
function fsRemoveNotEmptyDir() { | |
fs.mkdirSync('foo') | |
fs.openSync('foo/hoge.html', 'a') | |
fs.rmdirSync('foo') | |
// 失敗する。 | |
// Error: ENOTEMPTY: directory not empty, rmdir 'foo' | |
} | |
function rimrafRemoveNotEmptyDir() { | |
fs.mkdirSync('foo') | |
fs.openSync('foo/hoge.html', 'a') | |
rimraf('foo', function(error){}) | |
// 成功する。 | |
} | |
// fsRemoveEmptyDir() | |
// rimrafRemoveEmptyDir() | |
// fsRemoveNotEmptyDir() | |
// rimrafRemoveNotEmptyDir() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment