Skip to content

Commit 8201733

Browse files
authored
throw error if config is specified in pages (#1278)
1 parent b824226 commit 8201733

File tree

4 files changed

+39
-3
lines changed

4 files changed

+39
-3
lines changed

.changeset/rotten-radios-wink.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
Throw error if user attempts to use config with pages

packages/wrangler/src/__tests__/pages.test.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,6 @@ describe("pages", () => {
299299
directory The directory of static files to upload [string]
300300
301301
Flags:
302-
-c, --config Path to .toml configuration file [string]
303302
-h, --help Show help [boolean]
304303
-v, --version Show version number [boolean]
305304
@@ -969,6 +968,19 @@ describe("pages", () => {
969968

970969
expect(std.err).toMatchInlineSnapshot(`""`);
971970
});
971+
972+
it("should throw an error if user attempts to use config with pages", async () => {
973+
await expect(
974+
runWrangler("pages dev --config foo.toml")
975+
).rejects.toThrowErrorMatchingInlineSnapshot(
976+
`"Pages does not support wrangler.toml"`
977+
);
978+
await expect(
979+
runWrangler("pages publish --config foo.toml")
980+
).rejects.toThrowErrorMatchingInlineSnapshot(
981+
`"Pages does not support wrangler.toml"`
982+
);
983+
});
972984
});
973985

974986
describe("project upload", () => {

packages/wrangler/src/pages/dev.tsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ export function Options(yargs: Argv): Argv<PagesDevArgs> {
9292
type: "boolean",
9393
hidden: true,
9494
},
95+
config: {
96+
describe: "Pages does not support wrangler.toml",
97+
type: "string",
98+
hidden: true,
99+
},
95100
// // TODO: Miniflare user options
96101
})
97102
.epilogue(pagesBetaWarning);
@@ -108,14 +113,18 @@ export const Handler = async ({
108113
do: durableObjects = [],
109114
"live-reload": liveReload,
110115
"node-compat": nodeCompat,
116+
config: config,
111117
_: [_pages, _dev, ...remaining],
112118
}: ArgumentsCamelCase<PagesDevArgs>) => {
113119
// Beta message for `wrangler pages <commands>` usage
114120
logger.log(pagesBetaWarning);
115121

116122
if (!local) {
117-
logger.error("Only local mode is supported at the moment.");
118-
return;
123+
throw new FatalError("Only local mode is supported at the moment.", 1);
124+
}
125+
126+
if (config) {
127+
throw new FatalError("Pages does not support wrangler.toml", 1);
119128
}
120129

121130
const functionsDirectory = "./functions";

packages/wrangler/src/pages/publish.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ export function Options(yargs: Argv): Argv<PublishArgs> {
5959
description:
6060
"Whether or not the workspace should be considered dirty for this deployment",
6161
},
62+
config: {
63+
describe: "Pages does not support wrangler.toml",
64+
type: "string",
65+
hidden: true,
66+
},
6267
})
6368
.epilogue(pagesBetaWarning);
6469
}
@@ -70,7 +75,12 @@ export const Handler = async ({
7075
commitHash,
7176
commitMessage,
7277
commitDirty,
78+
config: wranglerConfig,
7379
}: ArgumentsCamelCase<PublishArgs>) => {
80+
if (wranglerConfig) {
81+
throw new FatalError("Pages does not support wrangler.toml", 1);
82+
}
83+
7484
if (!directory) {
7585
throw new FatalError("Must specify a directory.", 1);
7686
}

0 commit comments

Comments
 (0)