Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/auto-icons/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineWxtModule } from 'wxt/modules';
import { resolve, relative } from 'node:path';
import defu from 'defu';
import sharp from 'sharp';
import { ensureDir, exists } from 'fs-extra';
import { ensureDir, pathExists } from 'fs-extra';

export default defineWxtModule<AutoIconsOptions>({
name: '@wxt-dev/auto-icons',
Expand Down Expand Up @@ -37,7 +37,7 @@ export default defineWxtModule<AutoIconsOptions>({
if (!parsedOptions.enabled)
return wxt.logger.warn(`\`[auto-icons]\` ${this.name} disabled`);

if (!(await exists(resolvedPath))) {
if (!(await pathExists(resolvedPath))) {
return wxt.logger.warn(
`\`[auto-icons]\` Skipping icon generation, no base icon found at ${relative(process.cwd(), resolvedPath)}`,
);
Expand Down
4 changes: 2 additions & 2 deletions packages/runner/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ async function findBrowserBinary(target: string): Promise<string | undefined> {
for (const target of targets) {
const potentialPaths = KNOWN_BROWSER_PATHS[target]?.[platform] ?? [];
for (const path of potentialPaths) {
if (await exists(path)) return path;
if (await pathExists(path)) return path;
}
}
}
Expand Down Expand Up @@ -207,7 +207,7 @@ function deduplicateArgs(
return args;
}

async function exists(path: string): Promise<boolean> {
async function pathExists(path: string): Promise<boolean> {
try {
await open(path, 'r');
return true;
Expand Down
18 changes: 9 additions & 9 deletions packages/wxt/e2e/tests/analysis.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ describe('Analysis', () => {
},
});

expect(await project.fileExists('stats.html')).toBe(true);
expect(await project.fileExists('.output/chrome-mv3/stats-0.json')).toBe(
expect(await project.pathExists('stats.html')).toBe(true);
expect(await project.pathExists('.output/chrome-mv3/stats-0.json')).toBe(
false,
);
});
Expand All @@ -52,9 +52,9 @@ describe('Analysis', () => {
},
});

expect(await project.fileExists('stats.html')).toBe(true);
expect(await project.fileExists('stats-0.json')).toBe(true);
expect(await project.fileExists('stats-1.json')).toBe(true);
expect(await project.pathExists('stats.html')).toBe(true);
expect(await project.pathExists('stats-0.json')).toBe(true);
expect(await project.pathExists('stats-1.json')).toBe(true);
});

it('should support customizing the stats output directory', async () => {
Expand All @@ -73,7 +73,7 @@ describe('Analysis', () => {
},
});

expect(await project.fileExists('stats/bundle.html')).toBe(true);
expect(await project.pathExists('stats/bundle.html')).toBe(true);
});

it('should place artifacts next to the custom output file', async () => {
Expand All @@ -93,9 +93,9 @@ describe('Analysis', () => {
},
});

expect(await project.fileExists('stats/bundle.html')).toBe(true);
expect(await project.fileExists('stats/bundle-0.json')).toBe(true);
expect(await project.fileExists('stats/bundle-1.json')).toBe(true);
expect(await project.pathExists('stats/bundle.html')).toBe(true);
expect(await project.pathExists('stats/bundle-0.json')).toBe(true);
expect(await project.pathExists('stats/bundle-1.json')).toBe(true);
});

it('should open the stats in the browser when requested', async () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/wxt/e2e/tests/auto-imports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ describe('Auto Imports', () => {

await project.prepare();

expect(await project.fileExists('.wxt/types/imports.d.ts')).toBe(false);
expect(await project.pathExists('.wxt/types/imports.d.ts')).toBe(false);
});

it('should only include imports-module.d.ts in the the project', async () => {
Expand Down Expand Up @@ -280,10 +280,10 @@ describe('Auto Imports', () => {
},
});

expect(await project.fileExists('.wxt/eslint-auto-imports.mjs')).toBe(
expect(await project.pathExists('.wxt/eslint-auto-imports.mjs')).toBe(
false,
);
expect(await project.fileExists('.wxt/eslintrc-auto-import.json')).toBe(
expect(await project.pathExists('.wxt/eslintrc-auto-import.json')).toBe(
false,
);
});
Expand Down
6 changes: 3 additions & 3 deletions packages/wxt/e2e/tests/modules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('Module Helpers', () => {

await project.build(config);

expect(await project.fileExists('.output/chrome-mv3/injected.js')).toBe(
expect(await project.pathExists('.output/chrome-mv3/injected.js')).toBe(
true,
);
});
Expand Down Expand Up @@ -118,10 +118,10 @@ describe('Module Helpers', () => {
fileName: 'module.txt',
});
await expect(
project.fileExists('.output/chrome-mv3/module.txt'),
project.pathExists('.output/chrome-mv3/module.txt'),
).resolves.toBe(true);
await expect(
project.fileExists('.output/chrome-mv3/example/generated.txt'),
project.pathExists('.output/chrome-mv3/example/generated.txt'),
).resolves.toBe(true);
});

Expand Down
16 changes: 8 additions & 8 deletions packages/wxt/e2e/tests/output-structure.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ describe('Output Directory Structure', () => {

await project.build({ browser: 'firefox' });

expect(await project.fileExists('.output/firefox-mv2/background.js')).toBe(
expect(await project.pathExists('.output/firefox-mv2/background.js')).toBe(
false,
);
});
Expand All @@ -146,7 +146,7 @@ describe('Output Directory Structure', () => {

await project.build({ browser: 'chrome' });

expect(await project.fileExists('.output/firefox-mv2/background.js')).toBe(
expect(await project.pathExists('.output/firefox-mv2/background.js')).toBe(
false,
);
});
Expand Down Expand Up @@ -174,7 +174,7 @@ describe('Output Directory Structure', () => {

await project.build();

expect(await project.fileExists('stats.html')).toBe(true);
expect(await project.pathExists('stats.html')).toBe(true);
});

it('should support JavaScript entrypoints', async () => {
Expand Down Expand Up @@ -210,14 +210,14 @@ describe('Output Directory Structure', () => {
----------------------------------------
{"manifest_version":3,"name":"E2E Extension","description":"Example description","version":"0.0.0","background":{"service_worker":"background.js"},"content_scripts":[{"matches":["*://*.google.com/*"],"js":["content-scripts/content.js"]},{"matches":["*://*.duckduckgo.com/*"],"js":["content-scripts/named.js"]}]}"
`);
expect(await project.fileExists('.output/chrome-mv3/background.js'));
expect(await project.pathExists('.output/chrome-mv3/background.js'));
expect(
await project.fileExists('.output/chrome-mv3/content-scripts/content.js'),
await project.pathExists('.output/chrome-mv3/content-scripts/content.js'),
);
expect(
await project.fileExists('.output/chrome-mv3/content-scripts/named.js'),
await project.pathExists('.output/chrome-mv3/content-scripts/named.js'),
);
expect(await project.fileExists('.output/chrome-mv3/unlisted.js'));
expect(await project.pathExists('.output/chrome-mv3/unlisted.js'));
});

it('should support CSS entrypoints', async () => {
Expand Down Expand Up @@ -300,7 +300,7 @@ describe('Output Directory Structure', () => {

await project.build();

expect(await project.fileExists('dist/chrome-mv3/manifest.json')).toBe(
expect(await project.pathExists('dist/chrome-mv3/manifest.json')).toBe(
true,
);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/wxt/e2e/tests/react.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('React', () => {
await project.build();

expect(
await project.fileExists('.output/chrome-mv3/content-scripts/demo.js'),
await project.pathExists('.output/chrome-mv3/content-scripts/demo.js'),
).toBe(true);
expect(await project.serializeFile('.output/chrome-mv3/manifest.json'))
.toMatchInlineSnapshot(`
Expand Down
2 changes: 1 addition & 1 deletion packages/wxt/e2e/tests/remote-code.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Remote Code', () => {
);
expect(output).not.toContain(url);
expect(
await project.fileExists(`.wxt/cache/${encodeURIComponent(url)}`),
await project.pathExists(`.wxt/cache/${encodeURIComponent(url)}`),
).toBe(true);
});
});
6 changes: 3 additions & 3 deletions packages/wxt/e2e/tests/user-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('User Config', () => {
await project.build({ configFile: 'test.config.ts' });

expect(
await project.fileExists('.custom-output/chrome-mv3/background.js'),
await project.pathExists('.custom-output/chrome-mv3/background.js'),
).toBe(true);
});

Expand All @@ -129,13 +129,13 @@ describe('User Config', () => {
await project.build();

expect(
await project.fileExists('.output/test-chrome-mv3-production-build'),
await project.pathExists('.output/test-chrome-mv3-production-build'),
).toBe(true);

await project.build({ mode: 'development' });

expect(
await project.fileExists('.output/test-chrome-mv3-development-dev-build'),
await project.pathExists('.output/test-chrome-mv3-development-dev-build'),
).toBe(true);
});

Expand Down
36 changes: 18 additions & 18 deletions packages/wxt/e2e/tests/zip.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('Zipping', () => {
browser: 'firefox',
zip: { downloadPackages: ['flatten'] },
});
expect(await project.fileExists('.output/')).toBe(true);
expect(await project.pathExists('.output/')).toBe(true);

await extract(sourcesZip, { dir: unzipDir });
// Update package json wxt path
Expand All @@ -51,7 +51,7 @@ describe('Zipping', () => {
}),
).resolves.not.toHaveProperty('exitCode');

await expect(project.fileExists(unzipDir, '.output')).resolves.toBe(true);
await expect(project.pathExists(unzipDir, '.output')).resolves.toBe(true);
expect(
await project.serializeFile(
project.resolvePath(unzipDir, 'package.json'),
Expand Down Expand Up @@ -95,8 +95,8 @@ describe('Zipping', () => {
},
});

expect(await project.fileExists(artifactZip)).toBe(true);
expect(await project.fileExists(sourcesZip)).toBe(true);
expect(await project.pathExists(artifactZip)).toBe(true);
expect(await project.pathExists(sourcesZip)).toBe(true);
});

it('should not zip hidden files into sources by default', async () => {
Expand All @@ -117,8 +117,8 @@ describe('Zipping', () => {
browser: 'firefox',
});
await extract(sourcesZip, { dir: unzipDir });
expect(await project.fileExists(unzipDir, '.env')).toBe(false);
expect(await project.fileExists(unzipDir, '.hidden-dir/file')).toBe(false);
expect(await project.pathExists(unzipDir, '.env')).toBe(false);
expect(await project.pathExists(unzipDir, '.hidden-dir/file')).toBe(false);
});

it('should not zip files inside hidden directories if only the directory is specified', async () => {
Expand All @@ -142,8 +142,8 @@ describe('Zipping', () => {
},
});
await extract(sourcesZip, { dir: unzipDir });
expect(await project.fileExists(unzipDir, '.hidden-dir/file')).toBe(false);
expect(await project.fileExists(unzipDir, '.hidden-dir/nested/file')).toBe(
expect(await project.pathExists(unzipDir, '.hidden-dir/file')).toBe(false);
expect(await project.pathExists(unzipDir, '.hidden-dir/nested/file')).toBe(
false,
);
});
Expand Down Expand Up @@ -171,12 +171,12 @@ describe('Zipping', () => {
},
});
await extract(sourcesZip, { dir: unzipDir });
expect(await project.fileExists(unzipDir, '.env')).toBe(true);
expect(await project.fileExists(unzipDir, '.hidden-dir/file')).toBe(true);
expect(await project.fileExists(unzipDir, '.hidden-dir/nested/file1')).toBe(
expect(await project.pathExists(unzipDir, '.env')).toBe(true);
expect(await project.pathExists(unzipDir, '.hidden-dir/file')).toBe(true);
expect(await project.pathExists(unzipDir, '.hidden-dir/nested/file1')).toBe(
true,
);
expect(await project.fileExists(unzipDir, '.hidden-dir/nested/file2')).toBe(
expect(await project.pathExists(unzipDir, '.hidden-dir/nested/file2')).toBe(
true,
);
});
Expand Down Expand Up @@ -210,10 +210,10 @@ describe('Zipping', () => {
});
await extract(sourcesZip, { dir: unzipDir });
expect(
await project.fileExists(unzipDir, 'entrypoints/not-firefox.content.ts'),
await project.pathExists(unzipDir, 'entrypoints/not-firefox.content.ts'),
).toBe(false);
expect(
await project.fileExists(unzipDir, 'entrypoints/all.content.ts'),
await project.pathExists(unzipDir, 'entrypoints/all.content.ts'),
).toBe(true);
});

Expand All @@ -234,7 +234,7 @@ describe('Zipping', () => {
browser,
});

expect(await project.fileExists(sourcesZip)).toBe(true);
expect(await project.pathExists(sourcesZip)).toBe(true);
},
);

Expand All @@ -258,7 +258,7 @@ describe('Zipping', () => {
},
});

expect(await project.fileExists(sourcesZip)).toBe(true);
expect(await project.pathExists(sourcesZip)).toBe(true);
},
);

Expand All @@ -282,7 +282,7 @@ describe('Zipping', () => {
},
});

expect(await project.fileExists(sourcesZip)).toBe(false);
expect(await project.pathExists(sourcesZip)).toBe(false);
},
);

Expand All @@ -305,6 +305,6 @@ describe('Zipping', () => {
});

await extract(sourcesZip, { dir: unzipDir });
expect(await project.fileExists(unzipDir, 'manifest.json')).toBe(true);
expect(await project.pathExists(unzipDir, 'manifest.json')).toBe(true);
});
});
4 changes: 2 additions & 2 deletions packages/wxt/e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ export class TestProject {
].join(`\n${''.padEnd(40, '-')}\n`);
}

fileExists(...path: string[]): Promise<boolean> {
return fs.exists(this.resolvePath(...path));
pathExists(...path: string[]): Promise<boolean> {
return fs.pathExists(this.resolvePath(...path));
}

async getOutputManifest(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { exists } from 'fs-extra';
import { pathExists } from 'fs-extra';
import { resolve } from 'node:path';
import type * as vite from 'vite';
import { ResolvedConfig } from '../../../../types';
Expand All @@ -25,7 +25,7 @@ export function resolveAppConfig(config: ResolvedConfig): vite.Plugin {
async resolveId(id) {
if (id !== virtualModuleId) return;

return (await exists(appConfigFile))
return (await pathExists(appConfigFile))
? appConfigFile
: resolvedVirtualModuleId;
},
Expand Down
2 changes: 1 addition & 1 deletion packages/wxt/src/core/generate-wxt-dir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ declare module "wxt/browser" {
'messages.json',
);
let messages: Message[];
if (await fs.exists(defaultLocalePath)) {
if (await fs.pathExists(defaultLocalePath)) {
const content = JSON.parse(await fs.readFile(defaultLocalePath, 'utf-8'));
messages = parseI18nMessages(content);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { beforeAll, describe, expect, it } from 'vitest';
import path from 'node:path';
import { npm } from '../npm';
import spawn from 'nano-spawn';
import { exists } from 'fs-extra';
import { pathExists } from 'fs-extra';

describe('NPM Package Management Utils', () => {
describe('listDependencies', () => {
Expand Down Expand Up @@ -41,7 +41,7 @@ describe('NPM Package Management Utils', () => {
const actual = await npm.downloadDependency(id, downloadDir);

expect(actual).toEqual(expected);
expect(await exists(actual)).toBe(true);
expect(await pathExists(actual)).toBe(true);
});
});
});
Loading
Loading