Skip to content

Commit

Permalink
Refactor config snapshot cleaning for ini comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Apr 12, 2024
1 parent fb9d47a commit 983f8a5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test/lib/commands/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ const replaceJsonOrIni = (key) => [
`$1{${key.toUpperCase()}}`,
]

const replaceIniComment = (key) => [
new RegExp(`(; ${key} = ).*`, 'g'),
`$1{${key.replaceAll(' ', '-').toUpperCase()}}`,
]

t.cleanSnapshot = (s) => cleanCwd(s)
.replaceAll(/(; node version = ).*/g, '$1{NODE-VERSION}')
.replaceAll(/(; npm version = ).*/g, '$1{NPM-VERSION}')
.replaceAll(/(; node bin location = ).*/g, '$1{EXECPATH}')
.replaceAll(...replaceIniComment('node version'))
.replaceAll(...replaceIniComment('npm version'))
.replaceAll(...replaceIniComment('node bin location'))
.replaceAll(...replaceJsonOrIni('npm-version'))
.replaceAll(...replaceJsonOrIni('viewer'))
.replaceAll(...replaceJsonOrIni('shell'))
Expand Down

0 comments on commit 983f8a5

Please sign in to comment.