index.js 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. const optsArg = require('./lib/opts-arg.js')
  2. const pathArg = require('./lib/path-arg.js')
  3. const {mkdirpNative, mkdirpNativeSync} = require('./lib/mkdirp-native.js')
  4. const {mkdirpManual, mkdirpManualSync} = require('./lib/mkdirp-manual.js')
  5. const {useNative, useNativeSync} = require('./lib/use-native.js')
  6. const mkdirp = (path, opts) => {
  7. path = pathArg(path)
  8. opts = optsArg(opts)
  9. return useNative(opts)
  10. ? mkdirpNative(path, opts)
  11. : mkdirpManual(path, opts)
  12. }
  13. const mkdirpSync = (path, opts) => {
  14. path = pathArg(path)
  15. opts = optsArg(opts)
  16. return useNativeSync(opts)
  17. ? mkdirpNativeSync(path, opts)
  18. : mkdirpManualSync(path, opts)
  19. }
  20. mkdirp.sync = mkdirpSync
  21. mkdirp.native = (path, opts) => mkdirpNative(pathArg(path), optsArg(opts))
  22. mkdirp.manual = (path, opts) => mkdirpManual(pathArg(path), optsArg(opts))
  23. mkdirp.nativeSync = (path, opts) => mkdirpNativeSync(pathArg(path), optsArg(opts))
  24. mkdirp.manualSync = (path, opts) => mkdirpManualSync(pathArg(path), optsArg(opts))
  25. module.exports = mkdirp