From 9c11eaa4dcc0cd1dc3f51c96e754e64475b3a77f Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Fri, 5 Aug 2022 16:45:15 +0100 Subject: [PATCH] fix: order aliases from specific to general (#45) --- src/env.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/env.ts b/src/env.ts index d0df7540..fd47d2c9 100644 --- a/src/env.ts +++ b/src/env.ts @@ -11,7 +11,11 @@ export function env (...presets: Preset[]): Environment { for (const preset of presets) { // Alias if (preset.alias) { - for (const from in preset.alias) { + // Sort aliases from specific to general (ie. fs/promises before fs) + const aliases = Object.keys(preset.alias).sort((a, b) => + (b.split('/').length - a.split('/').length) || (b.length - a.length) + ) + for (const from of aliases) { _env.alias[from] = preset.alias[from] } }