-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CARNET-5; Fix broken symlink handling; <cargo>Fix broken symlink hand…
…ling</cargo> Root cause isaacs/rimraf#65 Root cause ember-cli/ember-cli#3413 Root cause Rich-Harris/sander#1 Fix #170
- Loading branch information
1 parent
504cf5e
commit 0e09f70
Showing
4 changed files
with
106 additions
and
5 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
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,78 @@ | ||
var fs = require('fs') | ||
var test = require('tap').test | ||
var glob = require('../') | ||
var mkdirp = require('mkdirp') | ||
|
||
process.chdir(__dirname) | ||
|
||
var link = 'a/broken-link/link' | ||
|
||
var patterns = [ | ||
'a/broken-link/*', | ||
'a/broken-link/**', | ||
'a/broken-link/**/link', | ||
'a/broken-link/**/*', | ||
'a/broken-link/link', | ||
'a/broken-link/{link,asdf}', | ||
'a/broken-link/+(link|asdf)', | ||
'a/broken-link/!(asdf)' | ||
] | ||
|
||
var opts = [ | ||
null, | ||
{ nonull: true }, | ||
{ mark: true }, | ||
{ stat: true } | ||
] | ||
|
||
test('set up broken symlink', function (t) { | ||
cleanup() | ||
mkdirp.sync('a/broken-link') | ||
fs.symlinkSync('this-does-not-exist', 'a/broken-link/link') | ||
t.end() | ||
}) | ||
|
||
test('async test', function (t) { | ||
var count = patterns.length * opts.length | ||
t.plan(patterns.length) | ||
patterns.forEach(function (pattern) { | ||
t.test(pattern, function (t) { | ||
t.plan(opts.length) | ||
|
||
opts.forEach(function (opt) { | ||
glob(pattern, opt, cb(opt)) | ||
}) | ||
|
||
function cb (opt) { return function (er, res) { | ||
if (er) | ||
throw er | ||
var msg = pattern + ' ' + JSON.stringify(opt) | ||
t.notEqual(res.indexOf(link), -1, msg) | ||
}} | ||
}) | ||
}) | ||
}) | ||
|
||
test('sync test', function (t) { | ||
t.plan(patterns.length) | ||
patterns.forEach(function (pattern) { | ||
t.test(pattern, function (t) { | ||
t.plan(opts.length) | ||
|
||
opts.forEach(function (opt) { | ||
var res = glob.sync(pattern, opt) | ||
t.notEqual(res.indexOf(link), -1, 'opt=' + JSON.stringify(opt)) | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
test('cleanup', function (t) { | ||
cleanup() | ||
t.end() | ||
}) | ||
|
||
function cleanup () { | ||
try { fs.unlinkSync('a/broken-link/link') } catch (e) {} | ||
try { fs.rmdirSync('a/broken-link') } catch (e) {} | ||
} |