Skip to content

Commit

Permalink
chore: simplify code (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb authored Feb 11, 2025
1 parent ce0ca9a commit 9e1c9e9
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function unenvPreset(opts: CreateEnvOptions) {
const preset = {
meta: {
name: "unenv",
version: version,
version,
url: import.meta.url,
},
alias: {},
Expand Down Expand Up @@ -152,11 +152,9 @@ function mergePresets(...presets: Preset[]): Environment {

// Inject
if (preset.inject) {
for (const global in preset.inject) {
const globalValue = preset.inject[global];
for (const [global, globalValue] of Object.entries(preset.inject)) {
if (Array.isArray(globalValue)) {
const [id, ...path] = globalValue;
env.inject[global] = [id, ...path];
env.inject[global] = globalValue;
} else if (globalValue === false) {
delete env.inject[global];
} else {
Expand All @@ -167,7 +165,7 @@ function mergePresets(...presets: Preset[]): Environment {

// Polyfill
if (preset.polyfill) {
env.polyfill.push(...(preset.polyfill.filter(Boolean) as string[]));
env.polyfill.push(...preset.polyfill.filter(Boolean));
}

// External
Expand Down

0 comments on commit 9e1c9e9

Please sign in to comment.