undergroundwires/privacy.sexy

View on GitHub
src/application/Context/State/Code/Generation/Languages/BatchBuilder.ts

Summary

Maintainability
A
1 hr
Test Coverage
import { CodeBuilder } from '@/application/Context/State/Code/Generation/CodeBuilder';

export class BatchBuilder extends CodeBuilder {
  protected getCommentDelimiter(): string {
    return '::';
  }

  protected writeStandardOut(text: string): string {
    return `echo ${escapeForEcho(text)}`;
  }

  protected getNewLineTerminator(): string {
    return '\r\n';
  }
}

function escapeForEcho(text: string) {
  return text
    .replace(/&/g, '^&')
    .replace(/%/g, '%%');
}