vils
Version:
Recursively outputs file paths and contents in various formats
19 lines (16 loc) • 644 B
text/typescript
import readline from 'readline';
export function escapeHTML(str: string): string {
return str.replace(/[&<>"']/g, tag => {
const map: any = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' };
return map[tag] || tag;
});
}
export async function promptConfirm(message: string): Promise<boolean> {
return new Promise(resolve => {
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
rl.question(message, answer => {
rl.close();
resolve(answer.trim().toLowerCase().startsWith('y'));
});
});
}