Skip to content

Commit 51093ed

Browse files
committed
Fix interactive prepublish test and bump version to 1.1.7
1 parent 2880026 commit 51093ed

3 files changed

Lines changed: 39 additions & 5 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "setup-node-api",
3-
"version": "1.1.6",
3+
"version": "1.1.7",
44
"description": "CLI tool to scaffold Node.js + Express APIs instantly",
55
"type": "commonjs",
66
"main": "bin/cli.js",

test/run-tests.js

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,36 @@ async function withTempDir(run) {
2525
}
2626
}
2727

28+
async function withInteractiveState(stdinIsTTY, stdoutIsTTY, run) {
29+
const stdinDescriptor = Object.getOwnPropertyDescriptor(process.stdin, "isTTY");
30+
const stdoutDescriptor = Object.getOwnPropertyDescriptor(process.stdout, "isTTY");
31+
32+
Object.defineProperty(process.stdin, "isTTY", {
33+
configurable: true,
34+
value: stdinIsTTY,
35+
});
36+
Object.defineProperty(process.stdout, "isTTY", {
37+
configurable: true,
38+
value: stdoutIsTTY,
39+
});
40+
41+
try {
42+
await run();
43+
} finally {
44+
if (stdinDescriptor) {
45+
Object.defineProperty(process.stdin, "isTTY", stdinDescriptor);
46+
} else {
47+
delete process.stdin.isTTY;
48+
}
49+
50+
if (stdoutDescriptor) {
51+
Object.defineProperty(process.stdout, "isTTY", stdoutDescriptor);
52+
} else {
53+
delete process.stdout.isTTY;
54+
}
55+
}
56+
}
57+
2858
function runCli(args, cwd) {
2959
try {
3060
return execFileSync(process.execPath, [cliPath, ...args], {
@@ -108,8 +138,12 @@ async function testTypeScriptTemplate() {
108138
}
109139

110140
async function testPromptDefaults() {
111-
const details = await askProjectDetails({
112-
projectName: "plain-api",
141+
let details;
142+
143+
await withInteractiveState(false, false, async () => {
144+
details = await askProjectDetails({
145+
projectName: "plain-api",
146+
});
113147
});
114148

115149
assert.deepEqual(details, {

0 commit comments

Comments
 (0)