Skip to content

Commit

Permalink
fixup! feat: experimental workers assets can be ignored by adding a .…
Browse files Browse the repository at this point in the history
…cfassetsignore file
  • Loading branch information
petebacondarwin committed Sep 6, 2024
1 parent 773f341 commit 904218c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
7 changes: 6 additions & 1 deletion .changeset/nasty-hats-rhyme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@
"wrangler": minor
---

feat: experimental workers assets can be ignored by adding a .cfassetsignore file
feat: experimental workers assets can be ignored by adding a .assetsignore file

This file can be added to the root of the assets directory that is to be uploaded alongside the Worker
when using `experimental_assets`.

The file follows the `.gitignore` syntax, and any matching paths will not be included in the upload.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"cSpell.words": [
"Abortable",
"cfassetsignore",
"assetsignore",
"cfetch",
"chatgpt",
"clipboardy",
Expand Down
4 changes: 2 additions & 2 deletions packages/wrangler/src/__tests__/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4371,9 +4371,9 @@ addEventListener('fetch', event => {});`
});
});

it("should ignore assets that match patterns in an .cfassetsignore file in the root of the assets directory", async () => {
it("should ignore assets that match patterns in an .assetsignore file in the root of the assets directory", async () => {
const assets = [
{ filePath: ".cfassetsignore", content: "*.bak\nsub-dir" },
{ filePath: ".assetsignore", content: "*.bak\nsub-dir" },
{ filePath: "file-1.txt", content: "Content of file-1" },
{ filePath: "file-2.bak", content: "Content of file-2" },
{ filePath: "file-3.txt", content: "Content of file-3" },
Expand Down
4 changes: 2 additions & 2 deletions packages/wrangler/src/experimental-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ const decodeFilepath = (filePath: string) => {
* and returns true if the asset should not be ignored.
*/
async function createAssetIgnoreFunction(dir: string) {
const CF_ASSETS_IGNORE_FILENAME = ".cfassetsignore";
const CF_ASSETS_IGNORE_FILENAME = ".assetsignore";

const cfAssetIgnorePath = path.resolve(dir, CF_ASSETS_IGNORE_FILENAME);

Expand All @@ -400,7 +400,7 @@ async function createAssetIgnoreFunction(dir: string) {
await readFile(cfAssetIgnorePath, { encoding: "utf8" })
).split("\n");

// Always ignore the `.cfassetsignore` file.
// Always ignore the `.assetsignore` file.
ignorePatterns.push(CF_ASSETS_IGNORE_FILENAME);

return createPatternMatcher(ignorePatterns, true);
Expand Down

0 comments on commit 904218c

Please sign in to comment.