2020-03-13 20:22:56 +00:00
|
|
|
// node native scope
|
2025-11-25 11:59:11 +00:00
|
|
|
import * as path from 'node:path';
|
|
|
|
|
import * as stream from 'node:stream';
|
|
|
|
|
import * as fs from 'node:fs';
|
|
|
|
|
import * as fsPromises from 'node:fs/promises';
|
2020-03-13 20:22:56 +00:00
|
|
|
|
2025-11-25 11:59:11 +00:00
|
|
|
export { path, stream, fs, fsPromises };
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* List files in a directory recursively, returning relative paths
|
|
|
|
|
*/
|
|
|
|
|
export async function listFileTree(dirPath: string, _pattern: string = '**/*'): Promise<string[]> {
|
|
|
|
|
const results: string[] = [];
|
|
|
|
|
|
|
|
|
|
async function walkDir(currentPath: string, relativePath: string = '') {
|
|
|
|
|
const entries = await fsPromises.readdir(currentPath, { withFileTypes: true });
|
|
|
|
|
for (const entry of entries) {
|
|
|
|
|
const entryRelPath = relativePath ? path.join(relativePath, entry.name) : entry.name;
|
|
|
|
|
const entryFullPath = path.join(currentPath, entry.name);
|
|
|
|
|
|
|
|
|
|
if (entry.isDirectory()) {
|
|
|
|
|
await walkDir(entryFullPath, entryRelPath);
|
|
|
|
|
} else if (entry.isFile()) {
|
|
|
|
|
results.push(entryRelPath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await walkDir(dirPath);
|
|
|
|
|
return results;
|
|
|
|
|
}
|
2020-03-13 20:22:56 +00:00
|
|
|
|
|
|
|
|
// @pushrocks scope
|
2023-07-26 16:13:33 +02:00
|
|
|
import * as smartfile from '@push.rocks/smartfile';
|
2024-03-17 00:29:42 +01:00
|
|
|
import * as smartdelay from '@push.rocks/smartdelay';
|
2023-07-26 16:13:33 +02:00
|
|
|
import * as smartpath from '@push.rocks/smartpath';
|
|
|
|
|
import * as smartpromise from '@push.rocks/smartpromise';
|
|
|
|
|
import * as smartrequest from '@push.rocks/smartrequest';
|
|
|
|
|
import * as smartunique from '@push.rocks/smartunique';
|
|
|
|
|
import * as smartstream from '@push.rocks/smartstream';
|
|
|
|
|
import * as smartrx from '@push.rocks/smartrx';
|
2023-11-06 18:14:21 +01:00
|
|
|
import * as smarturl from '@push.rocks/smarturl';
|
2020-03-13 20:22:56 +00:00
|
|
|
|
2025-08-18 01:29:06 +00:00
|
|
|
export {
|
|
|
|
|
smartfile,
|
|
|
|
|
smartdelay,
|
|
|
|
|
smartpath,
|
|
|
|
|
smartpromise,
|
|
|
|
|
smartrequest,
|
|
|
|
|
smartunique,
|
|
|
|
|
smartstream,
|
|
|
|
|
smartrx,
|
|
|
|
|
smarturl,
|
|
|
|
|
};
|
2020-03-13 20:22:56 +00:00
|
|
|
|
|
|
|
|
// third party scope
|
2023-11-06 18:14:21 +01:00
|
|
|
import * as fileType from 'file-type';
|
|
|
|
|
import * as fflate from 'fflate';
|
2021-04-19 11:49:25 +00:00
|
|
|
import tarStream from 'tar-stream';
|
2020-03-13 20:22:56 +00:00
|
|
|
|
2023-11-11 18:28:50 +01:00
|
|
|
export { fileType, fflate, tarStream };
|