Skip to content

Commit

Permalink
fix: order aliases from specific to general (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Aug 5, 2022
1 parent 70efe37 commit 9c11eaa
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
}
Expand Down

0 comments on commit 9c11eaa

Please sign in to comment.