| 1 |
'use strict' |
| 2 |
|
| 3 |
const assert = require('assert') |
| 4 |
const fse = require(process.cwd()) |
| 5 |
|
| 6 |
/* global describe, it */ |
| 7 |
|
| 8 |
describe('mkdirp: issue-209, win32, when bad path, should return a cleaner error', () => { |
| 9 |
// only seems to be an issue on Windows. |
| 10 |
if (process.platform !== 'win32') return |
| 11 |
|
| 12 |
it('should return a callback', done => { |
| 13 |
const file = './bad?dir' |
| 14 |
fse.mkdirp(file, err => { |
| 15 |
assert(err, 'error is present') |
| 16 |
assert.strictEqual(err.code, 'EINVAL') |
| 17 |
|
| 18 |
const file2 = 'c:\\tmp\foo:moo' |
| 19 |
fse.mkdirp(file2, err => { |
| 20 |
assert(err, 'error is present') |
| 21 |
assert.strictEqual(err.code, 'EINVAL') |
| 22 |
done() |
| 23 |
}) |
| 24 |
}) |
| 25 |
}) |
| 26 |
|
| 27 |
describe('> sync', () => { |
| 28 |
it('should throw an error', () => { |
| 29 |
let didErr |
| 30 |
try { |
| 31 |
const file = 'c:\\tmp\foo:moo' |
| 32 |
fse.mkdirpSync(file) |
| 33 |
} catch { |
| 34 |
didErr = true |
| 35 |
} |
| 36 |
assert(didErr) |
| 37 |
}) |
| 38 |
}) |
| 39 |
}) |