is-fs-access-available.js 763 B

12345678910111213141516171819202122
  1. 'use strict'
  2. var fs = require('fs')
  3. var semver = require('semver')
  4. var isWindows = process.platform === 'win32'
  5. // fs.access first introduced in node 0.12 / io.js
  6. if (!fs.access) {
  7. module.exports = false
  8. } else if (!isWindows) {
  9. // fs.access always works on non-Windows OSes
  10. module.exports = true
  11. } else {
  12. // The Windows implementation of `fs.access` has a bug where it will
  13. // sometimes return access errors all the time for directories, even
  14. // when access is available. As all we actually test ARE directories, this
  15. // is a bit of a problem.
  16. // This was fixed in io.js version 1.5.0
  17. // As of 2015-07-20, it is still unfixed in node:
  18. // https://github.com/joyent/node/issues/25657
  19. module.exports = semver.gte(process.version, '1.5.0')
  20. }