source: trip-planner-front/node_modules/mkdirp/lib/mkdirp-native.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 969 bytes
Line 
1const {dirname} = require('path')
2const {findMade, findMadeSync} = require('./find-made.js')
3const {mkdirpManual, mkdirpManualSync} = require('./mkdirp-manual.js')
4
5const mkdirpNative = (path, opts) => {
6 opts.recursive = true
7 const parent = dirname(path)
8 if (parent === path)
9 return opts.mkdirAsync(path, opts)
10
11 return findMade(opts, path).then(made =>
12 opts.mkdirAsync(path, opts).then(() => made)
13 .catch(er => {
14 if (er.code === 'ENOENT')
15 return mkdirpManual(path, opts)
16 else
17 throw er
18 }))
19}
20
21const mkdirpNativeSync = (path, opts) => {
22 opts.recursive = true
23 const parent = dirname(path)
24 if (parent === path)
25 return opts.mkdirSync(path, opts)
26
27 const made = findMadeSync(opts, path)
28 try {
29 opts.mkdirSync(path, opts)
30 return made
31 } catch (er) {
32 if (er.code === 'ENOENT')
33 return mkdirpManualSync(path, opts)
34 else
35 throw er
36 }
37}
38
39module.exports = {mkdirpNative, mkdirpNativeSync}
Note: See TracBrowser for help on using the repository browser.