This repository has been archived by the owner on Jun 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from seanmwalker/master
Windows permission change before unlinking files and symlinks is in and has better tests.
- Loading branch information
Showing
3 changed files
with
98 additions
and
10 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
var testCase = require('nodeunit').testCase; | ||
var fs = require('fs'); | ||
var wrench = require('../lib/wrench'); | ||
var path = require('path'); | ||
|
||
module.exports = testCase({ | ||
test_rmdirSyncRecursive: function(test) { | ||
var dir = __dirname + '/_tmp2/foo/bar'; | ||
|
||
wrench.mkdirSyncRecursive(dir, '777'); | ||
|
||
var f1Path = path.join(dir, 'test1.txt'); | ||
var f2Path = path.join(path.dirname(dir), 'test2.txt'); | ||
var f3Path = path.join(path.dirname(path.dirname(dir)), 'test3.txt'); | ||
|
||
fs.writeFileSync(f1Path, 'foo bar baz'); | ||
fs.writeFileSync(f2Path, 'foo bar baz'); | ||
fs.writeFileSync(f3Path, 'foo bar baz'); | ||
|
||
fs.chmodSync(f1Path, '777'); | ||
fs.chmodSync(f2Path, '777'); | ||
fs.chmodSync(f3Path, '777'); | ||
|
||
test.equals(fs.existsSync(dir), true, 'Dir should exist - mkdirSyncRecursive not working?'); | ||
test.equals(fs.existsSync(f1Path), true, 'File should exist'); | ||
test.equals(fs.existsSync(f2Path), true, 'File should exist'); | ||
test.equals(fs.existsSync(f3Path), true, 'File should exist'); | ||
|
||
wrench.rmdirSyncRecursive(dir); | ||
|
||
test.equals(fs.existsSync(dir), false, 'Dir should not exist now...'); | ||
test.equals(fs.existsSync(f1Path), false, 'File should not exist'); | ||
test.equals(fs.existsSync(f2Path), true, 'File should exist'); | ||
test.equals(fs.existsSync(f3Path), true, 'File should exist'); | ||
|
||
wrench.rmdirSyncRecursive(path.dirname(path.dirname(dir))); | ||
|
||
test.done(); | ||
}, | ||
|
||
test_rmdirSyncRecursiveFromRoot: function(test) { | ||
var dir = __dirname + '/_tmp3/foo/bar'; | ||
|
||
wrench.mkdirSyncRecursive(dir, '777'); | ||
|
||
var f1Path = path.join(dir, 'test1.txt'); | ||
var f2Path = path.join(path.dirname(dir), 'test2.txt'); | ||
var f3Path = path.join(path.dirname(path.dirname(dir)), 'test3.txt'); | ||
|
||
fs.writeFileSync(f1Path, 'foo bar baz'); | ||
fs.writeFileSync(f2Path, 'foo bar baz'); | ||
fs.writeFileSync(f3Path, 'foo bar baz'); | ||
|
||
fs.chmodSync(f1Path, '777'); | ||
fs.chmodSync(f2Path, '777'); | ||
fs.chmodSync(f3Path, '777'); | ||
|
||
test.equals(fs.existsSync(dir), true, 'Dir should exist - mkdirSyncRecursive not working?'); | ||
test.equals(fs.existsSync(f1Path), true, 'File should exist'); | ||
test.equals(fs.existsSync(f2Path), true, 'File should exist'); | ||
test.equals(fs.existsSync(f3Path), true, 'File should exist'); | ||
|
||
wrench.rmdirSyncRecursive(path.dirname(path.dirname(dir))); | ||
|
||
test.equals(fs.existsSync(dir), false, 'Dir should not exist now...'); | ||
test.equals(fs.existsSync(f1Path), false, 'File should not exist'); | ||
test.equals(fs.existsSync(f2Path), false, 'File should not exist'); | ||
test.equals(fs.existsSync(f3Path), false, 'File should not exist'); | ||
|
||
test.done(); | ||
} | ||
}); | ||
|
||
// vim: et ts=4 sw=4 |
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