1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const fs = require("fs");
|
4 | const path = require("path");
|
5 | const util_1 = require("util");
|
6 | const klaw = require("klaw");
|
7 | const rimraf = require("rimraf");
|
8 | exports.fsAccess = util_1.promisify(fs.access);
|
9 | exports.fsMkdir = util_1.promisify(fs.mkdir);
|
10 | exports.fsOpen = util_1.promisify(fs.open);
|
11 | exports.fsStat = util_1.promisify(fs.stat);
|
12 | exports.fsUnlink = util_1.promisify(fs.unlink);
|
13 | exports.fsReadFile = util_1.promisify(fs.readFile);
|
14 | exports.fsWriteFile = util_1.promisify(fs.writeFile);
|
15 | exports.fsReadDir = util_1.promisify(fs.readdir);
|
16 | exports.fsRemoveDir = util_1.promisify(rimraf);
|
17 | async 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 | }
|
34 | exports.findFiles = findFiles;
|