Skip to content

Commit

Permalink
fix: better envify support
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Dec 3, 2022
1 parent d67d4c8 commit 58766f9
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,17 @@ class Axe {
constructor(config = {}) {
const remappedFields = {};
if (process.env.AXE_REMAPPED_META_FIELDS) {
const arr = process.env.AXE_REMAPPED_META_FIELDS.split(',').map((v) =>
v.split(':')
);
const fields = process.env.AXE_REMAPPED_META_FIELDS;
const arr = fields.split(',').map((v) => v.split(':'));
for (const [prop, value] of arr) {
remappedFields[prop] = value;
}
}

// envify does not support conditionals well enough so we declare vars outside
const omittedFields = process.env.AXE_OMIT_META_FIELDS;
const pickedFields = process.env.AXE_PICK_META_FIELDS;

this.config = mergeOptions(
{
showStack: process.env.AXE_SHOW_STACK
Expand All @@ -118,11 +121,11 @@ class Axe {
? boolean(process.env.AXE_SHOW_META)
: true,
remappedFields,
omittedFields: process.env.AXE_OMIT_META_FIELDS
? process.env.AXE_OMIT_META_FIELDS.split(',').map((s) => s.trim())
omittedFields: omittedFields
? omittedFields.split(',').map((s) => s.trim())
: [],
pickedFields: process.env.AXE_PICK_META_FIELDS
? process.env.AXE_PICK_META_FIELDS.split(',').map((s) => s.trim())
pickedFields: pickedFields
? pickedFields.split(',').map((s) => s.trim())
: [],
cleanupRemapping: true,
hideHTTP: true
Expand Down

0 comments on commit 58766f9

Please sign in to comment.