From 983f8a57b274e784a5ef0ca8600629d0fe4bb292 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Fri, 12 Apr 2024 10:47:11 -0700 Subject: [PATCH] Refactor config snapshot cleaning for ini comments --- test/lib/commands/config.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/lib/commands/config.js b/test/lib/commands/config.js index b2c0d35f7bfd3..0806326e2e8e4 100644 --- a/test/lib/commands/config.js +++ b/test/lib/commands/config.js @@ -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'))