Files
smartarchive/ts/plugins.ts

54 lines
1.6 KiB
TypeScript

// Node.js native scope
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';
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;
}
// Re-export browser-compatible plugins from ts_shared
export * from '../ts_shared/plugins.js';
// Additional Node.js-specific @pushrocks packages
import * as smartpath from '@push.rocks/smartpath';
import * as smartrequest from '@push.rocks/smartrequest';
import * as smartunique from '@push.rocks/smartunique';
import * as smartrx from '@push.rocks/smartrx';
import * as smarturl from '@push.rocks/smarturl';
export {
smartpath,
smartrequest,
smartunique,
smartrx,
smarturl,
};
// Node.js-specific: tar-stream for true streaming TAR support
import * as tarStream from 'tar-stream';
export { tarStream };