Use line endings based on script language #88

Use CRLF in batchfile and LF in shellscript.
This commit is contained in:
undergroundwires
2022-09-28 23:09:23 +02:00
parent bbc6156281
commit 6b3f4659df
6 changed files with 89 additions and 2 deletions

View File

@@ -1,6 +1,5 @@
import { ICodeBuilder } from './ICodeBuilder';
const NewLine = '\n';
const TotalFunctionSeparatorChars = 58;
export abstract class CodeBuilder implements ICodeBuilder {
@@ -59,10 +58,12 @@ export abstract class CodeBuilder implements ICodeBuilder {
}
public toString(): string {
return this.lines.join(NewLine);
return this.lines.join(this.getNewLineTerminator());
}
protected abstract getCommentDelimiter(): string;
protected abstract writeStandardOut(text: string): string;
protected abstract getNewLineTerminator(): string;
}

View File

@@ -8,6 +8,10 @@ export class BatchBuilder extends CodeBuilder {
protected writeStandardOut(text: string): string {
return `echo ${escapeForEcho(text)}`;
}
protected getNewLineTerminator(): string {
return '\r\n';
}
}
function escapeForEcho(text: string) {

View File

@@ -8,6 +8,10 @@ export class ShellBuilder extends CodeBuilder {
protected writeStandardOut(text: string): string {
return `echo '${escapeForEcho(text)}'`;
}
protected getNewLineTerminator(): string {
return '\n';
}
}
function escapeForEcho(text: string) {