diff --git a/lib/fs/index.js b/lib/fs/index.js index 43529653..1821fd00 100644 --- a/lib/fs/index.js +++ b/lib/fs/index.js @@ -9,6 +9,7 @@ const api = [ 'chmod', 'chown', 'close', + 'copyFile', 'fchmod', 'fchown', 'fdatasync', @@ -20,6 +21,7 @@ const api = [ 'link', 'lstat', 'mkdir', + 'mkdtemp', 'open', 'readFile', 'readdir', @@ -33,12 +35,13 @@ const api = [ 'unlink', 'utimes', 'writeFile' -] -// Add methods that are only in some Node.js versions -// fs.copyFile was added in Node.js v8.5.0 -typeof fs.copyFile === 'function' && api.push('copyFile') -// fs.mkdtemp() was added in Node.js v5.10.0 -typeof fs.mkdtemp === 'function' && api.push('mkdtemp') +].filter(key => { + // Some commands are not available on some systems. Ex: + // fs.copyFile was added in Node.js v8.5.0 + // fs.mkdtemp was added in Node.js v5.10.0 + // fs.lchown is not available on at least some Linux + return typeof fs[key] === 'function' +}) // Export all keys: Object.keys(fs).forEach(key => {