UNPKG

1.12 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const fs = require("fs");
4const path = require("path");
5const util_1 = require("util");
6const klaw = require("klaw");
7const rimraf = require("rimraf");
8exports.fsAccess = util_1.promisify(fs.access);
9exports.fsMkdir = util_1.promisify(fs.mkdir);
10exports.fsOpen = util_1.promisify(fs.open);
11exports.fsStat = util_1.promisify(fs.stat);
12exports.fsUnlink = util_1.promisify(fs.unlink);
13exports.fsReadFile = util_1.promisify(fs.readFile);
14exports.fsWriteFile = util_1.promisify(fs.writeFile);
15exports.fsReadDir = util_1.promisify(fs.readdir);
16exports.fsRemoveDir = util_1.promisify(rimraf);
17async function findFiles(p, name) {
18 const files = [];
19 return new Promise((resolve, reject) => {
20 klaw(p)
21 .on('data', item => {
22 if (path.basename(item.path) === name) {
23 files.push(item.path);
24 }
25 })
26 .on('error', err => {
27 reject(err);
28 })
29 .on('end', () => {
30 resolve(files);
31 });
32 });
33}
34exports.findFiles = findFiles;