Browse Source

Refactor mkdirsSync

ci/travis-osximage
JPeer264 8 years ago
parent
commit
a0d25cfde4
  1. 18
      lib/mkdirs/mkdirs-sync.js

18
lib/mkdirs/mkdirs-sync.js

@ -1,19 +1,21 @@
var fs = require('graceful-fs') 'use strict'
var path = require('path')
var invalidWin32Path = require('./win32').invalidWin32Path
var o777 = parseInt('0777', 8) const fs = require('graceful-fs')
const path = require('path')
const invalidWin32Path = require('./win32').invalidWin32Path
const o777 = parseInt('0777', 8)
function mkdirsSync (p, opts, made) { function mkdirsSync (p, opts, made) {
if (!opts || typeof opts !== 'object') { if (!opts || typeof opts !== 'object') {
opts = { mode: opts } opts = { mode: opts }
} }
var mode = opts.mode let mode = opts.mode
var xfs = opts.fs || fs const xfs = opts.fs || fs
if (process.platform === 'win32' && invalidWin32Path(p)) { if (process.platform === 'win32' && invalidWin32Path(p)) {
var errInval = new Error(p + ' contains invalid WIN32 path characters.') const errInval = new Error(p + ' contains invalid WIN32 path characters.')
errInval.code = 'EINVAL' errInval.code = 'EINVAL'
throw errInval throw errInval
} }
@ -40,7 +42,7 @@ function mkdirsSync (p, opts, made) {
// there already. If so, then hooray! If not, then something // there already. If so, then hooray! If not, then something
// is borked. // is borked.
default: default:
var stat let stat
try { try {
stat = xfs.statSync(p) stat = xfs.statSync(p)
} catch (err1) { } catch (err1) {

Loading…
Cancel
Save