MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / mkdirp

Function mkdirp

javascript/selenium-webdriver/io/index.js:280–305  ·  view source on GitHub ↗

* Recursively creates a directory and any ancestors that do not yet exist. * * @param {string} dir The directory path to create. * @return {!Promise } A promise that will resolve with the path of the * created directory.

(dir)

Source from the content-addressed store, hash-verified

278 * created directory.
279 */
280function mkdirp(dir) {
281 return checkedCall((callback) => {
282 fs.mkdir(dir, undefined, (err) => {
283 if (!err) {
284 callback(null, dir)
285 return
286 }
287
288 switch (err.code) {
289 case 'EEXIST':
290 callback(null, dir)
291 return
292 case 'ENOENT':
293 return mkdirp(path.dirname(dir))
294 .then(() => mkdirp(dir))
295 .then(
296 () => callback(null, dir),
297 (err) => callback(err),
298 )
299 default:
300 callback(err)
301 return
302 }
303 })
304 })
305}
306
307/**
308 * Recursively walks a directory, returning a promise that will resolve with

Callers

nothing calls this directly

Calls 2

checkedCallFunction · 0.85
callbackFunction · 0.85

Tested by

no test coverage detected