Skip to content

Commit

Permalink
fix: set envDir to cwd
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed Nov 14, 2024
1 parent 946be81 commit b5cd561
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function getViteConfig(
css: {
postcss: resolvedPostCssConfig,
},
envDir: options.cwd,
envPrefix: ['VITE_', 'KIRBYUP_'],
customLogger: logger,
logLevel,
Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ exports[`supports built-in env variables 1`] = `
`;

exports[`supports custom env variables 1`] = `
"var kirbyupExport=function(e){"use strict";var t={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};const o=t.KIRBYUP_FOO;return e.foo=o,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
"var kirbyupExport=function(o){"use strict";const r="bar";return o.foo=r,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),o}({});
"
`;

Expand Down
6 changes: 3 additions & 3 deletions test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as fsp from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
import { remove } from 'fs-extra'
import { resolve } from 'pathe'
import { afterAll, beforeAll, expect, it, vi } from 'vitest'
import { cacheDir, runCli } from './utils'
Expand All @@ -9,12 +9,12 @@ const currentDir = fileURLToPath(new URL('.', import.meta.url))
beforeAll(async () => {
// Unset so kirbyup applies its default environment setting
vi.stubEnv('NODE_ENV', '')
await remove(cacheDir)
await fsp.rm(cacheDir, { recursive: true, force: true })
})

afterAll(async () => {
vi.unstubAllEnvs()
await remove(cacheDir)
await fsp.rm(cacheDir, { recursive: true, force: true })
})

it('builds index.js', async () => {
Expand Down

0 comments on commit b5cd561

Please sign in to comment.