diff --git a/lib/mkdir.js b/lib/mkdir.js index 382329ef..c6a154c2 100644 --- a/lib/mkdir.js +++ b/lib/mkdir.js @@ -69,7 +69,7 @@ const mkdir = module.exports = (dir, opt, cb) => { return done() if (dir === cwd) - return fs.lstat(dir, (er, st) => { + return fs.stat(dir, (er, st) => { if (er || !st.isDirectory()) er = new CwdError(dir, er && er.code || 'ENOTDIR') done(er) @@ -154,7 +154,7 @@ const mkdirSync = module.exports.sync = (dir, opt) => { let ok = false let code = 'ENOTDIR' try { - ok = fs.lstatSync(dir).isDirectory() + ok = fs.statSync(dir).isDirectory() } catch (er) { code = er.code } finally { diff --git a/test/unpack.js b/test/unpack.js index 33a9d2f6..e190dfcb 100644 --- a/test/unpack.js +++ b/test/unpack.js @@ -79,9 +79,12 @@ t.test('basic file unpack tests', t => { t.test(tarfile, t => { const tf = path.resolve(tars, tarfile) const dir = path.resolve(basedir, tarfile) + const linkdir = path.resolve(basedir, tarfile + '.link') t.beforeEach(cb => { rimraf.sync(dir) + rimraf.sync(linkdir) mkdirp.sync(dir) + fs.symlinkSync(dir, linkdir) cb() }) @@ -99,12 +102,12 @@ t.test('basic file unpack tests', t => { t.test('async unpack', t => { t.plan(2) t.test('strict', t => { - const unpack = new Unpack({ cwd: dir, strict: true }) + const unpack = new Unpack({ cwd: linkdir, strict: true }) fs.createReadStream(tf).pipe(unpack) eos(unpack, _ => check(t)) }) t.test('loose', t => { - const unpack = new Unpack({ cwd: dir }) + const unpack = new Unpack({ cwd: linkdir }) fs.createReadStream(tf).pipe(unpack) eos(unpack, _ => check(t)) }) @@ -113,12 +116,12 @@ t.test('basic file unpack tests', t => { t.test('sync unpack', t => { t.plan(2) t.test('strict', t => { - const unpack = new UnpackSync({ cwd: dir }) + const unpack = new UnpackSync({ cwd: linkdir }) unpack.end(fs.readFileSync(tf)) check(t) }) t.test('loose', t => { - const unpack = new UnpackSync({ cwd: dir }) + const unpack = new UnpackSync({ cwd: linkdir }) unpack.end(fs.readFileSync(tf)) check(t) })