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
8 changes: 5 additions & 3 deletions src/commands/env-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ export default createCommand(config, async ({ positionals }) => {
if (environment === repo) {
await adapter.unsetEnvironment();
console.info(`Reset to the production environment "${repo}".`);
return;
} else {
await adapter.setEnvironment(environment);
console.info(`Set the active environment to "${environment}".`);
}

await adapter.setEnvironment(environment);
console.info(`Set the active environment to "${environment}".`);
const setupInstructions = await adapter.getSetupInstructions();
if (setupInstructions) console.info(`\n${setupInstructions}`);
});
6 changes: 6 additions & 0 deletions test/env-set.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ it("clears the active environment when setting to production", async ({
expect(after).not.toContain("my-stage-env");
});

it("prints setup instructions", async ({ expect, prismic, repo }) => {
const { stdout, exitCode } = await prismic("env", ["set", repo]);
expect(exitCode).toBe(0);
expect(stdout).toContain("Action required: add <PrismicPreview> to your root layout.");
});

it("rejects an unknown environment", async ({ expect, prismic }) => {
const { exitCode } = await prismic("env", ["set", "does-not-exist"]);
expect(exitCode).toBe(1);
Expand Down
Loading