|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- 'use strict'
-
- const fs = require('fs')
-
- const { promisify } = require('util')
-
- module.exports = { ...fs }
-
- // Promisify all functions for consistency
- const fns = [
- 'access',
- 'appendFile',
- 'chmod',
- 'chown',
- 'close',
- 'copyFile',
- 'fchmod',
- 'fchown',
- 'fdatasync',
- 'fstat',
- 'fsync',
- 'ftruncate',
- 'futimes',
- 'lchmod',
- 'lchown',
- 'link',
- 'lstat',
- 'mkdir',
- 'mkdtemp',
- 'open',
- 'read',
- 'readdir',
- 'readFile',
- 'readlink',
- 'realpath',
- 'rename',
- 'rmdir',
- 'stat',
- 'symlink',
- 'truncate',
- 'unlink',
- 'utimes',
- 'write',
- 'writeFile'
- ]
- fns.forEach(fn => {
- /* istanbul ignore else: all functions exist on OSX */
- if (fs[fn]) {
- module.exports[fn] = promisify(fs[fn])
- }
- })
|