Skip to content

Commit

Permalink
fix: remove newline. it does nothing
Browse files Browse the repository at this point in the history
  • Loading branch information
rintaun committed Nov 29, 2020
1 parent 94b13f0 commit 855b63f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 19 deletions.
12 changes: 1 addition & 11 deletions src/cli/commands/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { close, open, write } from 'fs'
import { promisify } from 'util'
import { Arguments, Argv, BuilderCallback } from 'yargs'

import { Generator, GeneratorOptions } from '../..'
import { Generator } from '../..'

import { Params } from '../'
import { createPool } from 'slonik'
Expand All @@ -22,7 +22,6 @@ export interface GenerateParams extends Params {
genInsertTypes: boolean
genTables: boolean
genTypeObjects: boolean
newline: Required<GeneratorOptions>['newline']
}

export const builder: BuilderCallback<Params, GenerateParams> = (yargs: Argv) =>
Expand Down Expand Up @@ -62,14 +61,6 @@ export const builder: BuilderCallback<Params, GenerateParams> = (yargs: Argv) =>
default: true,
group: 'Generation options',
},
newline: {
alias: 'N',
requiresArg: true,
choices: ['lf', 'crlf'] as ReadonlyArray<GeneratorOptions['newline']>,
description: "Type of newline to use",
default: 'lf' as GeneratorOptions['newline'],
group: 'Generation options',
},
})
.version(false)

Expand All @@ -89,7 +80,6 @@ export const handler = async (argv: Arguments<GenerateParams>) => {

const generator = new Generator({
schema: schemaInfo,
newline: argv.newline,
genEnums: argv.genEnums,
genTables: argv.genTables,
genInsertTypes: argv.genInsertTypes,
Expand Down
1 change: 0 additions & 1 deletion src/cli/params.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export interface Params {
database: string
newline: 'lf' | 'crlf'
schema: string
}
8 changes: 1 addition & 7 deletions src/generator/Generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { SchemaInfo, TypeRegistry } from './database'

export interface GeneratorOptions {
schema: SchemaInfo
newline?: 'lf' | 'crlf'
genEnums?: boolean
genInsertTypes?: boolean
genTables?: boolean
Expand All @@ -31,18 +30,13 @@ export default class Generator {

constructor({
schema,
newline = 'lf',
genEnums = true,
genInsertTypes = true,
genTables = true,
genTypeObjects = true,
}: GeneratorOptions) {
if (newline !== 'lf' && newline !== 'crlf') {
console.warn(`Unknown newline type '${newline}' received. Acceptable values: lf, crlf. Defaulting to 'lf'.`)
}

this.printer = createPrinter({
newLine: newline === 'crlf' ? NewLineKind.CarriageReturnLineFeed : NewLineKind.LineFeed,
newLine: NewLineKind.LineFeed,
removeComments: false,
})

Expand Down

0 comments on commit 855b63f

Please sign in to comment.