use-native.js 448 B

12345678910
  1. const fs = require('fs')
  2. const version = process.env.__TESTING_MKDIRP_NODE_VERSION__ || process.version
  3. const versArr = version.replace(/^v/, '').split('.')
  4. const hasNative = +versArr[0] > 10 || +versArr[0] === 10 && +versArr[1] >= 12
  5. const useNative = !hasNative ? () => false : opts => opts.mkdir === fs.mkdir
  6. const useNativeSync = !hasNative ? () => false : opts => opts.mkdirSync === fs.mkdirSync
  7. module.exports = {useNative, useNativeSync}