Skip to content

Commit

Permalink
feat: Extrait logique dans un helper
Browse files Browse the repository at this point in the history
  • Loading branch information
bjlaa committed May 15, 2024
1 parent a6f9212 commit ab403c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 2 additions & 6 deletions source/migrations/migrateSituation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DottedName, MigrationType, Situation } from '../../types/types'
import { getValueWithoutQuotes } from './migrateSituation/getValueWithoutQuotes'
import { handleSituationKeysMigration } from './migrateSituation/handleSituationKeysMigration'
import { handleSituationValuesMigration } from './migrateSituation/handleSituationValuesMigration'
import { handleSpecialCases } from './migrateSituation/handleSpecialCases'
Expand Down Expand Up @@ -47,12 +48,7 @@ export function migrateSituation({
]

const formattedNodeValue =
typeof nodeValue === 'string' &&
nodeValue.startsWith("'") &&
nodeValue !== 'oui' &&
nodeValue !== 'non'
? nodeValue.slice(1, -1)
: (nodeValue as string)
getValueWithoutQuotes(nodeValue) || (nodeValue as string)

if (
// We check if the value of the non supported ruleName value is a value to migrate.
Expand Down
11 changes: 11 additions & 0 deletions source/migrations/migrateSituation/getValueWithoutQuotes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export function getValueWithoutQuotes(value: string | number) {
if (
typeof value !== 'string' ||
!value.startsWith("'") ||
value === 'oui' ||
value === 'non'
) {
return null
}
return value.slice(1, -1)
}

0 comments on commit ab403c4

Please sign in to comment.