Force EOL to be as defined, otherwise default from OS

This commit is contained in:
Paolo Ceschi Berrini 2020-01-14 13:31:04 +01:00
parent e76b68729e
commit 6289c351b1

View File

@ -3,6 +3,7 @@ import * as Prettier from "prettier";
import * as changeCase from "change-case";
import * as fs from "fs";
import * as path from "path";
import { EOL } from "os";
import IConnectionOptions from "./IConnectionOptions";
import IGenerationOptions from "./IGenerationOptions";
import { Entity } from "./models/Entity";
@ -71,7 +72,14 @@ function generateModels(
`${casedFileName}.ts`
);
const rendered = entityCompliedTemplate(element);
const withImportStatements = removeUnusedImports(rendered);
const withImportStatements = removeUnusedImports(
EOL !== generationOptions.convertEol
? rendered.replace(
/(\r\n|\n|\r)/gm,
generationOptions.convertEol
)
: rendered
);
const formatted = Prettier.format(withImportStatements, {
parser: "typescript"
});