Skip to content

Commit

Permalink
Hopefully fix Windows tests
Browse files Browse the repository at this point in the history
- Error codes are different
- Match fs.mkdir behavior on Windows when creating root
  • Loading branch information
RyanZim committed Feb 6, 2020
1 parent f6d7665 commit 64a3e2b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/mkdirs/__tests__/issue-93.test.js
Expand Up @@ -24,12 +24,12 @@ describe('mkdirp: issue-93, win32, when drive does not exist, it should return a
it('should return a cleaner error than inifinite loop, stack crash', done => {
const file = 'R:\\afasd\\afaff\\fdfd' // hopefully drive 'r' does not exist on appveyor
fse.mkdirp(file, err => {
assert.strictEqual(err.code, 'ENOENT')
assert.strictEqual(err.code, 'EPERM')

try {
fse.mkdirsSync(file)
} catch (err) {
assert.strictEqual(err.code, 'ENOENT')
assert.strictEqual(err.code, 'EPERM')
}

done()
Expand Down
10 changes: 5 additions & 5 deletions lib/mkdirs/__tests__/root.test.js
Expand Up @@ -8,17 +8,17 @@ const assert = require('assert')
/* global describe, it */

describe('mkdirp / root', () => {
// '/' on unix, 'c:/' on windows.
// '/' on unix
const dir = path.normalize(path.resolve(path.sep)).toLowerCase()

// if not 'c:\\' or 'd:\\', it's probably a network mounted drive, this fails then. TODO: investigate
if (process.platform === 'win32' && (dir.indexOf('c:\\') === -1) && (dir.indexOf('d:\\') === -1)) return
// Windows does not have permission to mkdir on root
if (process.platform === 'win32') return

it('should', done => {
fse.mkdirp(dir, 0o755, err => {
if (err) throw err
if (err) return done(err)
fs.stat(dir, (er, stat) => {
if (er) throw er
if (er) return done(er)
assert.ok(stat.isDirectory(), 'target is a directory')
done()
})
Expand Down

0 comments on commit 64a3e2b

Please sign in to comment.