diff --git a/packages/adapter-cloudflare/test/apps/workers/test/test.js b/packages/adapter-cloudflare/test/apps/workers/test/test.js index 40072953a16f..44832c70890f 100644 --- a/packages/adapter-cloudflare/test/apps/workers/test/test.js +++ b/packages/adapter-cloudflare/test/apps/workers/test/test.js @@ -1,10 +1,7 @@ import fs from 'node:fs'; import path from 'node:path'; -import { fileURLToPath } from 'node:url'; import { expect, test } from '@playwright/test'; -const __dirname = path.dirname(fileURLToPath(import.meta.url)); - test('worker', async ({ page }) => { await page.goto('/'); await expect(page.locator('h1')).toContainText('Sum: 3'); @@ -16,7 +13,10 @@ test('ctx', async ({ request }) => { }); test('read from $app/server works', async ({ request }) => { - const content = fs.readFileSync(path.resolve(__dirname, '../src/routes/read/file.txt'), 'utf-8'); + const content = fs.readFileSync( + path.resolve(import.meta.dirname, '../src/routes/read/file.txt'), + 'utf-8' + ); const response = await request.get('/read'); expect(await response.text()).toBe(content); }); diff --git a/packages/adapter-netlify/test/apps/basic/test/test.js b/packages/adapter-netlify/test/apps/basic/test/test.js index 89d91598c165..b208dd54a8b7 100644 --- a/packages/adapter-netlify/test/apps/basic/test/test.js +++ b/packages/adapter-netlify/test/apps/basic/test/test.js @@ -1,10 +1,7 @@ import fs from 'node:fs'; import path from 'node:path'; -import { fileURLToPath } from 'node:url'; import { expect, test } from '@playwright/test'; -const __dirname = path.dirname(fileURLToPath(import.meta.url)); - test('page renders', async ({ request }) => { const response = await request.get('/'); expect(response.status()).toBe(200); @@ -18,17 +15,23 @@ test('dynamic route works', async ({ request }) => { }); test('read from $app/server works', async ({ request }) => { - const content = fs.readFileSync(path.resolve(__dirname, '../src/routes/read/file.txt'), 'utf-8'); + const content = fs.readFileSync( + path.resolve(import.meta.dirname, '../src/routes/read/file.txt'), + 'utf-8' + ); const response = await request.get('/read'); expect(await response.text()).toBe(content); }); test('_redirects are copied to publish directory', () => { - const redirects = fs.readFileSync(path.resolve(__dirname, '../build/_redirects'), 'utf-8'); + const redirects = fs.readFileSync( + path.resolve(import.meta.dirname, '../build/_redirects'), + 'utf-8' + ); expect(redirects).toContain('/redirect-me /greeting/redirected 301'); }); test('_headers are copied to publish directory', () => { - const headers = fs.readFileSync(path.resolve(__dirname, '../build/_headers'), 'utf-8'); + const headers = fs.readFileSync(path.resolve(import.meta.dirname, '../build/_headers'), 'utf-8'); expect(headers).toContain('X-Custom-Header: test-value'); }); diff --git a/packages/adapter-netlify/test/apps/edge/test/test.js b/packages/adapter-netlify/test/apps/edge/test/test.js index 8053aaa563a2..11818baa35c5 100644 --- a/packages/adapter-netlify/test/apps/edge/test/test.js +++ b/packages/adapter-netlify/test/apps/edge/test/test.js @@ -1,10 +1,7 @@ import fs from 'node:fs'; import path from 'node:path'; -import { fileURLToPath } from 'node:url'; import { expect, test } from '@playwright/test'; -const __dirname = path.dirname(fileURLToPath(import.meta.url)); - test('page renders', async ({ request }) => { const response = await request.get('/'); expect(response.status()).toBe(200); @@ -18,12 +15,15 @@ test('dynamic route works', async ({ request }) => { }); test('read from $app/server works', async ({ request }) => { - const content = fs.readFileSync(path.resolve(__dirname, '../src/routes/read/file.txt'), 'utf-8'); + const content = fs.readFileSync( + path.resolve(import.meta.dirname, '../src/routes/read/file.txt'), + 'utf-8' + ); const response = await request.get('/read'); expect(await response.text()).toBe(content); }); test('_headers are copied to publish directory', () => { - const headers = fs.readFileSync(path.resolve(__dirname, '../build/_headers'), 'utf-8'); + const headers = fs.readFileSync(path.resolve(import.meta.dirname, '../build/_headers'), 'utf-8'); expect(headers).toContain('X-Custom-Header: test-value'); }); diff --git a/packages/enhanced-img/test/markup-plugin.spec.js b/packages/enhanced-img/test/markup-plugin.spec.js index b6dacafe3ec1..33b9288a6c0c 100644 --- a/packages/enhanced-img/test/markup-plugin.spec.js +++ b/packages/enhanced-img/test/markup-plugin.spec.js @@ -3,7 +3,7 @@ import path from 'node:path'; import { expect, it } from 'vitest'; import { image_plugin, parse_object } from '../src/vite-plugin.js'; -const resolve = /** @param {string} file */ (file) => path.resolve(__dirname, file); +const resolve = /** @param {string} file */ (file) => path.resolve(import.meta.dirname, file); it('Image preprocess snapshot test', async () => { const filename = 'Input.svelte'; diff --git a/packages/kit/src/core/adapt/builder.spec.js b/packages/kit/src/core/adapt/builder.spec.js index b69c7b8296bb..304a1ba5987d 100644 --- a/packages/kit/src/core/adapt/builder.spec.js +++ b/packages/kit/src/core/adapt/builder.spec.js @@ -6,11 +6,8 @@ import { create_builder } from './builder.js'; import { posixify } from '../../utils/filesystem.js'; import { list_files } from '../utils.js'; -const __filename = fileURLToPath(import.meta.url); -const __dirname = join(__filename, '..'); - test('copy files', () => { - const cwd = join(__dirname, 'fixtures/basic'); + const cwd = join(import.meta.dirname, 'fixtures/basic'); const outDir = join(cwd, '.svelte-kit'); /** @type {import('@sveltejs/kit').Config} */ @@ -19,7 +16,7 @@ test('copy files', () => { kit: { appDir: '_app', files: { - assets: join(__dirname, 'fixtures/basic/static') + assets: join(import.meta.dirname, 'fixtures/basic/static') }, outDir } @@ -42,7 +39,7 @@ test('copy files', () => { log: {} }); - const dest = join(__dirname, 'output'); + const dest = join(import.meta.dirname, 'output'); rmSync(dest, { recursive: true, force: true }); @@ -74,8 +71,8 @@ test('compress files', async () => { }); test('instrument generates facade with posix paths', () => { - const fixtureDir = join(__dirname, 'fixtures/instrument'); - const dest = join(__dirname, 'output'); + const fixtureDir = join(import.meta.dirname, 'fixtures/instrument'); + const dest = join(import.meta.dirname, 'output'); rmSync(dest, { recursive: true, force: true }); mkdirSync(join(dest, 'server'), { recursive: true }); diff --git a/packages/kit/src/core/config/index.spec.js b/packages/kit/src/core/config/index.spec.js index 549538e20d18..5a32221a0d58 100644 --- a/packages/kit/src/core/config/index.spec.js +++ b/packages/kit/src/core/config/index.spec.js @@ -1,12 +1,8 @@ import { join } from 'node:path'; -import { fileURLToPath } from 'node:url'; import { assert, expect, test } from 'vitest'; import { validate_config, load_config } from './index.js'; import process from 'node:process'; -const __filename = fileURLToPath(import.meta.url); -const __dirname = join(__filename, '..'); - /** * mutates and remove keys from an object when check callback returns true * @param {Record} o any object @@ -362,7 +358,7 @@ validate_paths( ); test('load default config (esm)', async () => { - const cwd = join(__dirname, 'fixtures/default'); + const cwd = join(import.meta.dirname, 'fixtures/default'); const config = await load_config({ cwd }); remove_keys(config, ([, v]) => typeof v === 'function'); @@ -374,7 +370,7 @@ test('load default config (esm)', async () => { }); test('load default config (esm) with .ts extensions', async () => { - const cwd = join(__dirname, 'fixtures/typescript'); + const cwd = join(import.meta.dirname, 'fixtures/typescript'); const config = await load_config({ cwd }); remove_keys(config, ([, v]) => typeof v === 'function'); @@ -386,7 +382,7 @@ test('load default config (esm) with .ts extensions', async () => { }); test('load .js config when both .js and .ts configs are present', async () => { - const cwd = join(__dirname, 'fixtures/multiple'); + const cwd = join(import.meta.dirname, 'fixtures/multiple'); const config = await load_config({ cwd }); remove_keys(config, ([, v]) => typeof v === 'function'); @@ -401,7 +397,7 @@ test('errors on loading config with incorrect default export', async () => { let message = null; try { - const cwd = join(__dirname, 'fixtures', 'export-string'); + const cwd = join(import.meta.dirname, 'fixtures', 'export-string'); await load_config({ cwd }); } catch (/** @type {any} */ e) { message = e.message; @@ -505,7 +501,7 @@ test('errors on invalid forkPreloads values', () => { }); test('uses src prefix for other kit.files options', async () => { - const cwd = join(__dirname, 'fixtures/custom-src'); + const cwd = join(import.meta.dirname, 'fixtures/custom-src'); const config = await load_config({ cwd }); remove_keys(config, ([, v]) => typeof v === 'function'); diff --git a/packages/kit/test/apps/dev-only/test/test.js b/packages/kit/test/apps/dev-only/test/test.js index 1b9099a923f1..6e2a96dd8782 100644 --- a/packages/kit/test/apps/dev-only/test/test.js +++ b/packages/kit/test/apps/dev-only/test/test.js @@ -3,9 +3,6 @@ import { test } from '../../../utils.js'; import fs from 'node:fs'; import path from 'node:path'; import process from 'node:process'; -import { fileURLToPath } from 'node:url'; - -const __dirname = path.dirname(fileURLToPath(import.meta.url)); /** @typedef {import('@playwright/test').Response} Response */ @@ -86,7 +83,10 @@ test.describe('Vite', () => { await page.goto('/'); await page.getByText('hello world!').waitFor(); - const manifest_path = path.join(__dirname, '../node_modules/.vite/deps/_metadata.json'); + const manifest_path = path.join( + import.meta.dirname, + '../node_modules/.vite/deps/_metadata.json' + ); const manifest = JSON.parse(fs.readFileSync(manifest_path, 'utf-8')); expect(manifest).toHaveProperty('optimized.e2e-test-dep-page-svelte'); @@ -96,7 +96,10 @@ test.describe('Vite', () => { await page.goto('/'); await page.getByText('hello world!').waitFor(); - const manifest_path = path.join(__dirname, '../node_modules/.vite/deps/_metadata.json'); + const manifest_path = path.join( + import.meta.dirname, + '../node_modules/.vite/deps/_metadata.json' + ); const manifest = JSON.parse(fs.readFileSync(manifest_path, 'utf-8')); expect(manifest).toHaveProperty('optimized.e2e-test-dep-page-universal'); @@ -106,7 +109,10 @@ test.describe('Vite', () => { await page.goto('/'); await page.getByText('hello world!').waitFor(); - const manifest_path = path.join(__dirname, '../node_modules/.vite/deps/_metadata.json'); + const manifest_path = path.join( + import.meta.dirname, + '../node_modules/.vite/deps/_metadata.json' + ); const manifest = JSON.parse(fs.readFileSync(manifest_path, 'utf-8')); expect(manifest).not.toHaveProperty('optimized.e2e-test-dep-page-server'); @@ -116,7 +122,10 @@ test.describe('Vite', () => { await page.goto('/'); await page.getByText('hello world!').waitFor(); - const manifest_path = path.join(__dirname, '../node_modules/.vite/deps/_metadata.json'); + const manifest_path = path.join( + import.meta.dirname, + '../node_modules/.vite/deps/_metadata.json' + ); const manifest = JSON.parse(fs.readFileSync(manifest_path, 'utf-8')); expect(manifest).toHaveProperty('optimized.e2e-test-dep-layout-svelte'); @@ -126,7 +135,10 @@ test.describe('Vite', () => { await page.goto('/'); await page.getByText('hello world!').waitFor(); - const manifest_path = path.join(__dirname, '../node_modules/.vite/deps/_metadata.json'); + const manifest_path = path.join( + import.meta.dirname, + '../node_modules/.vite/deps/_metadata.json' + ); const manifest = JSON.parse(fs.readFileSync(manifest_path, 'utf-8')); expect(manifest).toHaveProperty('optimized.e2e-test-dep-layout-universal'); @@ -136,7 +148,10 @@ test.describe('Vite', () => { await page.goto('/'); await page.getByText('hello world!').waitFor(); - const manifest_path = path.join(__dirname, '../node_modules/.vite/deps/_metadata.json'); + const manifest_path = path.join( + import.meta.dirname, + '../node_modules/.vite/deps/_metadata.json' + ); const manifest = JSON.parse(fs.readFileSync(manifest_path, 'utf-8')); expect(manifest).not.toHaveProperty('optimized.e2e-test-dep-layout-server'); @@ -146,7 +161,10 @@ test.describe('Vite', () => { await page.goto('/'); await page.getByText('hello world!').waitFor(); - const manifest_path = path.join(__dirname, '../node_modules/.vite/deps/_metadata.json'); + const manifest_path = path.join( + import.meta.dirname, + '../node_modules/.vite/deps/_metadata.json' + ); const manifest = JSON.parse(fs.readFileSync(manifest_path, 'utf-8')); expect(manifest).toHaveProperty('optimized.e2e-test-dep-error'); @@ -156,7 +174,10 @@ test.describe('Vite', () => { await page.goto('/'); await page.getByText('hello world!').waitFor(); - const manifest_path = path.join(__dirname, '../node_modules/.vite/deps/_metadata.json'); + const manifest_path = path.join( + import.meta.dirname, + '../node_modules/.vite/deps/_metadata.json' + ); const manifest = JSON.parse(fs.readFileSync(manifest_path, 'utf-8')); expect(manifest).toHaveProperty('optimized.e2e-test-dep-hooks-client'); @@ -166,7 +187,10 @@ test.describe('Vite', () => { await page.goto('/'); await page.getByText('hello world!').waitFor(); - const manifest_path = path.join(__dirname, '../node_modules/.vite/deps/_metadata.json'); + const manifest_path = path.join( + import.meta.dirname, + '../node_modules/.vite/deps/_metadata.json' + ); const manifest = JSON.parse(fs.readFileSync(manifest_path, 'utf-8')); expect(manifest).toHaveProperty('optimized.e2e-test-dep-hooks'); diff --git a/packages/kit/test/apps/options-2/test/test.js b/packages/kit/test/apps/options-2/test/test.js index f3df40146a8d..8a1d74487ab8 100644 --- a/packages/kit/test/apps/options-2/test/test.js +++ b/packages/kit/test/apps/options-2/test/test.js @@ -1,6 +1,5 @@ import path from 'node:path'; import process from 'node:process'; -import { fileURLToPath } from 'node:url'; import { expect } from '@playwright/test'; import { test } from '../../../utils.js'; @@ -126,11 +125,10 @@ test.describe('trailing slash', () => { test.describe('Service worker', () => { if (process.env.DEV) { test('import proxy /basepath/service-worker.js', async ({ request }) => { - const __dirname = path.dirname(fileURLToPath(import.meta.url)); const response = await request.get('/basepath/service-worker.js'); const content = await response.text(); expect(content).toEqual( - `import '${path.join('/basepath', '/@fs', __dirname, '../src/service-worker.js')}';` + `import '${path.join('/basepath', '/@fs', import.meta.dirname, '../src/service-worker.js')}';` ); }); diff --git a/packages/kit/test/apps/writes/test/test.js b/packages/kit/test/apps/writes/test/test.js index e513c647f37d..83c069633829 100644 --- a/packages/kit/test/apps/writes/test/test.js +++ b/packages/kit/test/apps/writes/test/test.js @@ -18,8 +18,10 @@ test.describe('Filesystem updates', () => { // future test file that has the same name const route = 'zzzz' + Date.now(); const content = 'Hello new route'; - const __dirname = path.dirname(fileURLToPath(import.meta.url)); - const filepath = path.join(__dirname, `../src/routes/new-route/${route}/+page.svelte`); + const filepath = path.join( + import.meta.dirname, + `../src/routes/new-route/${route}/+page.svelte` + ); const dir = path.dirname(filepath); try { diff --git a/packages/kit/test/build-errors/env.spec.js b/packages/kit/test/build-errors/env.spec.js index aa41d4db6545..061d6a3c9a77 100644 --- a/packages/kit/test/build-errors/env.spec.js +++ b/packages/kit/test/build-errors/env.spec.js @@ -13,7 +13,7 @@ test('$env/dynamic/private is not statically importable from the client', { time assert.throws( () => execSync('pnpm build', { - cwd: path.join(process.cwd(), 'apps/private-dynamic-env'), + cwd: path.join(import.meta.dirname, 'apps/private-dynamic-env'), stdio: 'pipe', timeout, env @@ -26,7 +26,7 @@ test('$env/dynamic/private is not dynamically importable from the client', { tim assert.throws( () => execSync('pnpm build', { - cwd: path.join(process.cwd(), 'apps/private-dynamic-env-dynamic-import'), + cwd: path.join(import.meta.dirname, 'apps/private-dynamic-env-dynamic-import'), stdio: 'pipe', timeout, env @@ -39,7 +39,7 @@ test('$env/static/private is not statically importable from the client', { timeo assert.throws( () => execSync('pnpm build', { - cwd: path.join(process.cwd(), 'apps/private-static-env'), + cwd: path.join(import.meta.dirname, 'apps/private-static-env'), stdio: 'pipe', timeout, env @@ -52,7 +52,7 @@ test('$env/static/private is not dynamically importable from the client', { time assert.throws( () => execSync('pnpm build', { - cwd: path.join(process.cwd(), 'apps/private-static-env-dynamic-import'), + cwd: path.join(import.meta.dirname, 'apps/private-static-env-dynamic-import'), stdio: 'pipe', timeout, env @@ -65,7 +65,7 @@ test('$env/dynamic/private is not importable from the service worker', { timeout assert.throws( () => execSync('pnpm build', { - cwd: path.join(process.cwd(), 'apps/service-worker-private-env'), + cwd: path.join(import.meta.dirname, 'apps/service-worker-private-env'), stdio: 'pipe', timeout, env @@ -78,7 +78,7 @@ test('$env/dynamic/public is not importable from the service worker', { timeout assert.throws( () => execSync('pnpm build', { - cwd: path.join(process.cwd(), 'apps/service-worker-dynamic-public-env'), + cwd: path.join(import.meta.dirname, 'apps/service-worker-dynamic-public-env'), stdio: 'pipe', timeout, env diff --git a/packages/kit/test/build-errors/prerender.spec.js b/packages/kit/test/build-errors/prerender.spec.js index 903d2491e858..e788055bac8b 100644 --- a/packages/kit/test/build-errors/prerender.spec.js +++ b/packages/kit/test/build-errors/prerender.spec.js @@ -2,7 +2,6 @@ import { assert, test } from 'vitest'; import { execSync } from 'node:child_process'; import path from 'node:path'; import { EOL } from 'node:os'; -import process from 'node:process'; const timeout = 60_000; @@ -10,7 +9,7 @@ test('prerenderable routes must be prerendered', { timeout }, () => { assert.throws( () => execSync('pnpm build', { - cwd: path.join(process.cwd(), 'apps/prerenderable-not-prerendered'), + cwd: path.join(import.meta.dirname, 'apps/prerenderable-not-prerendered'), stdio: 'pipe', timeout }), @@ -22,7 +21,7 @@ test('entry generators should match their own route', { timeout }, () => { assert.throws( () => execSync('pnpm build', { - cwd: path.join(process.cwd(), 'apps/prerender-entry-generator-mismatch'), + cwd: path.join(import.meta.dirname, 'apps/prerender-entry-generator-mismatch'), stdio: 'pipe', timeout }), @@ -34,7 +33,7 @@ test('an error in a `prerender` function should fail the build', { timeout }, () assert.throws( () => execSync('pnpm build', { - cwd: path.join(process.cwd(), 'apps/prerender-remote-function-error'), + cwd: path.join(import.meta.dirname, 'apps/prerender-remote-function-error'), stdio: 'pipe', timeout }), diff --git a/packages/kit/test/build-errors/server-only.spec.js b/packages/kit/test/build-errors/server-only.spec.js index 67bccd96afd3..1de049a8ff56 100644 --- a/packages/kit/test/build-errors/server-only.spec.js +++ b/packages/kit/test/build-errors/server-only.spec.js @@ -13,7 +13,7 @@ test('$lib/*.server.* is not statically importable from the client', { timeout } assert.throws( () => execSync('pnpm build', { - cwd: path.join(process.cwd(), 'apps/server-only-module'), + cwd: path.join(import.meta.dirname, 'apps/server-only-module'), stdio: 'pipe', timeout, env @@ -26,7 +26,7 @@ test('$lib/*.server.* is not dynamically importable from the client', { timeout assert.throws( () => execSync('pnpm build', { - cwd: path.join(process.cwd(), 'apps/server-only-module-dynamic-import'), + cwd: path.join(import.meta.dirname, 'apps/server-only-module-dynamic-import'), stdio: 'pipe', timeout, env @@ -39,7 +39,7 @@ test('$lib/server/* is not statically importable from the client', { timeout }, assert.throws( () => execSync('pnpm build', { - cwd: path.join(process.cwd(), 'apps/server-only-folder'), + cwd: path.join(import.meta.dirname, 'apps/server-only-folder'), stdio: 'pipe', timeout, env @@ -52,7 +52,7 @@ test('$lib/server/* is not dynamically importable from the client', { timeout }, assert.throws( () => execSync('pnpm build', { - cwd: path.join(process.cwd(), 'apps/server-only-folder-dynamic-import'), + cwd: path.join(import.meta.dirname, 'apps/server-only-folder-dynamic-import'), stdio: 'pipe', timeout, env diff --git a/packages/kit/test/build-errors/syntax-error.spec.js b/packages/kit/test/build-errors/syntax-error.spec.js index 9abc21f59ba2..5d0456b761f6 100644 --- a/packages/kit/test/build-errors/syntax-error.spec.js +++ b/packages/kit/test/build-errors/syntax-error.spec.js @@ -1,14 +1,13 @@ import { assert, test } from 'vitest'; import { execSync } from 'node:child_process'; import path from 'node:path'; -import process from 'node:process'; const timeout = 60_000; test('$lib/*.server.* is not statically importable from the client', { timeout }, () => { try { execSync('pnpm build', { - cwd: path.join(process.cwd(), 'apps/syntax-error'), + cwd: path.join(import.meta.dirname, 'apps/syntax-error'), stdio: 'pipe', timeout }); diff --git a/packages/package/test/index.spec.js b/packages/package/test/index.spec.js index e972d823ed4f..4ed145ca1abf 100644 --- a/packages/package/test/index.spec.js +++ b/packages/package/test/index.spec.js @@ -1,7 +1,6 @@ import fs from 'node:fs'; import process from 'node:process'; import { join, resolve } from 'node:path'; -import { fileURLToPath } from 'node:url'; import prettier from 'prettier'; import { test, expect } from 'vitest'; @@ -12,15 +11,12 @@ import { rimraf, walk } from '../src/filesystem.js'; import { _create_validator } from '../src/validate.js'; import { resolve_aliases } from '../src/utils.js'; -const __filename = fileURLToPath(import.meta.url); -const __dirname = join(__filename, '..'); - /** * @param {string} path * @param {Partial} [options] */ async function test_make_package(path, options) { - const cwd = join(__dirname, 'fixtures', path); + const cwd = join(import.meta.dirname, 'fixtures', path); const ewd = join(cwd, 'expected'); const output = join(cwd, 'dist'); @@ -85,9 +81,9 @@ async function format(file, content) { }); } -for (const dir of fs.readdirSync(join(__dirname, 'errors'))) { +for (const dir of fs.readdirSync(join(import.meta.dirname, 'errors'))) { test(`package error [${dir}]`, async () => { - const cwd = join(__dirname, 'errors', dir); + const cwd = join(import.meta.dirname, 'errors', dir); const output = join(cwd, 'dist'); const config = await load_config({ cwd }); @@ -177,7 +173,7 @@ test('create package with tsconfig specified', async () => { // chokidar doesn't fire events in github actions :shrug: if (!process.env.CI) { test('watches for changes', async () => { - const cwd = join(__dirname, 'watch'); + const cwd = join(import.meta.dirname, 'watch'); const config = await load_config({ cwd }); @@ -197,7 +193,7 @@ if (!process.env.CI) { /** @param {string} file */ function read(file) { - return fs.readFileSync(join(__dirname, 'watch', file), 'utf-8'); + return fs.readFileSync(join(import.meta.dirname, 'watch', file), 'utf-8'); } /** @@ -205,12 +201,12 @@ if (!process.env.CI) { * @param {string} data */ function write(file, data) { - return fs.writeFileSync(join(__dirname, 'watch', file), data); + return fs.writeFileSync(join(import.meta.dirname, 'watch', file), data); } /** @param {string} file */ function remove(file) { - const filepath = join(__dirname, 'watch', file); + const filepath = join(import.meta.dirname, 'watch', file); if (fs.existsSync(filepath)) fs.unlinkSync(filepath); } @@ -346,7 +342,7 @@ test('validates package (all ok 2)', () => { }); test('create package with preserved output', async () => { - const output = join(__dirname, 'fixtures', 'preserve-output', 'dist'); + const output = join(import.meta.dirname, 'fixtures', 'preserve-output', 'dist'); rimraf(output); fs.mkdirSync(join(output, 'assets'), { recursive: true }); fs.writeFileSync(join(output, 'assets', 'theme.css'), ':root { color: red }');