Skip to content

Commit

Permalink
fixed(#3): issue where last internal line of the classes contents are…
Browse files Browse the repository at this point in the history
… truncated; resulting in some models missing a property
  • Loading branch information
tomgobich committed Nov 13, 2024
1 parent 0a8de0d commit a5d1e0c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion services/file_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class FileService {
const classEndIndex = fileLines.findLastIndex((line) => string.condenseWhitespace(line) === '}')

const classLines = fileLines
.slice(classStartIndex + 1, classEndIndex - 1)
.slice(classStartIndex + 1, classEndIndex)
.map((line) => string.condenseWhitespace(line))

let isInBlock: boolean = false
Expand Down
2 changes: 2 additions & 0 deletions test-files/expectations/some_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import Test from '#models/test'
export default class SomeTestDto extends BaseModelDto {
declare id: number
declare createdAt: string
declare updatedAt: string

constructor(test?: Test) {
super()

if (!test) return
this.id = test.id
this.createdAt = test.createdAt.toISO()!
this.updatedAt = test.updatedAt.toISO()!
}
}
2 changes: 2 additions & 0 deletions test-files/expectations/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import Test from '#models/test'
export default class TestDto extends BaseModelDto {
declare id: number
declare createdAt: string
declare updatedAt: string

constructor(test?: Test) {
super()

if (!test) return
this.id = test.id
this.createdAt = test.createdAt.toISO()!
this.updatedAt = test.updatedAt.toISO()!
}
}
3 changes: 3 additions & 0 deletions test-files/expectations/user.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import TransactionDto from '#dtos/transaction'
import IncomeDto from '#dtos/income'
import StockPurchaseDto from '#dtos/stock_purchase'
import StockDto from '#dtos/stock'
import AccountDto from '#dtos/account'

export default class UserDto extends BaseModelDto {
declare id: number
Expand All @@ -18,6 +19,7 @@ export default class UserDto extends BaseModelDto {
declare incomes: IncomeDto[]
declare stockPurchases: StockPurchaseDto[]
declare stocks: StockDto[]
declare accounts: AccountDto[]

constructor(user?: User) {
super()
Expand All @@ -34,5 +36,6 @@ export default class UserDto extends BaseModelDto {
this.incomes = IncomeDto.fromArray(user.incomes)
this.stockPurchases = StockPurchaseDto.fromArray(user.stockPurchases)
this.stocks = StockDto.fromArray(user.stocks)
this.accounts = AccountDto.fromArray(user.accounts)
}
}

0 comments on commit a5d1e0c

Please sign in to comment.