3 const fs = require('fs');
4 const call = require('../call');
7 * A facade around {@link fs.readdirSync} that allows it to be called
8 * the same way as {@link fs.readdir}.
11 * @param {function} callback
13 exports.readdir = function (dir, callback) {
14 // Make sure the callback is only called once
15 callback = call.once(callback);
18 let items = fs.readdirSync(dir);
19 callback(null, items);
27 * A facade around {@link fs.statSync} that allows it to be called
28 * the same way as {@link fs.stat}.
30 * @param {string} path
31 * @param {function} callback
33 exports.stat = function (path, callback) {
34 // Make sure the callback is only called once
35 callback = call.once(callback);
38 let stats = fs.statSync(path);
39 callback(null, stats);
47 * A facade around {@link fs.lstatSync} that allows it to be called
48 * the same way as {@link fs.lstat}.
50 * @param {string} path
51 * @param {function} callback
53 exports.lstat = function (path, callback) {
54 // Make sure the callback is only called once
55 callback = call.once(callback);
58 let stats = fs.lstatSync(path);
59 callback(null, stats);