Skip to content

Commit 8516a14

Browse files
authored
tidier build prompt (#1286)
* tidier build prompt * fix deploy tests * prettier
1 parent 3f9d576 commit 8516a14

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/deploy.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,16 @@ export async function deploy(
221221
const mostRecentSourceMtimeMs = await findMostRecentSourceMtimeMs(effects, config);
222222
const buildAge = Date.now() - leastRecentBuildMtimeMs;
223223
let initialValue = buildAge > BUILD_AGE_WARNING_MS;
224-
let message = "";
225224
if (mostRecentSourceMtimeMs > leastRecentBuildMtimeMs) {
226-
message += "Your source files have changed since the last time you built. ";
225+
clack.log.warn(
226+
wrapAnsi(`Your source files have changed since you built ${formatAge(buildAge)}.`, effects.outputColumns)
227+
);
227228
initialValue = true;
229+
} else {
230+
clack.log.info(wrapAnsi(`You built this project ${formatAge(buildAge)}.`, effects.outputColumns));
228231
}
229-
message += `You built this project ${formatAge(buildAge)}. `;
230-
message += "Would you like to build again before deploying?";
231232
const choice = await clack.confirm({
232-
message,
233+
message: "Would you like to build again before deploying?",
233234
initialValue,
234235
active: "Yes, build and then deploy",
235236
inactive: "No, deploy as is"

test/deploy-test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,10 @@ describe("deploy", () => {
777777
fixedInputStatTime: new Date("2024-03-09"),
778778
fixedOutputStatTime: new Date("2024-03-10")
779779
});
780-
await assert.rejects(() => deploy(deployOptions, effects), /out of inputs for select: You built this project/);
780+
await assert.rejects(
781+
() => deploy(deployOptions, effects),
782+
/out of inputs for select: Would you like to build again/
783+
);
781784
effects.close();
782785
});
783786

@@ -794,7 +797,7 @@ describe("deploy", () => {
794797
});
795798
await assert.rejects(
796799
() => deploy(deployOptions, effects),
797-
/out of inputs for select: Your source files have changed/
800+
/out of inputs for select: Would you like to build again/
798801
);
799802
effects.close();
800803
});

0 commit comments

Comments
 (0)