Skip to content

Commit bd50b8b

Browse files
authored
Merge pull request #14 from dtarnawsky/non-interactive
feat: add non interactive mode for the CLI
2 parents 58fd09a + 3cf3bd6 commit bd50b8b

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

packages/cli/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
"@angular-eslint/template-parser": "^16.1.2",
66
"@clack/core": "^0.3.3",
77
"@clack/prompts": "^0.7.0",
8+
"@ionic/utils-terminal": "^2.3.4",
89
"picocolors": "^1.0.0",
910
"ts-dedent": "^2.2.0",
10-
"ts-morph": "^19.0.0"
11+
"ts-morph": "^19.0.0"
1112
},
1213
"bin": "./dist/index.js",
1314
"files": [

packages/cli/src/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
spinner,
1111
} from "@clack/prompts";
1212
import color from "picocolors";
13-
13+
import { TERMINAL_INFO } from '@ionic/utils-terminal';
1414
import { Project } from "ts-morph";
1515
import { existsSync } from "node:fs";
1616

@@ -21,6 +21,8 @@ const IONIC_MIGRATION_GUIDE_URL =
2121
"https://www.ionicframework.com/docs/angular/build-options#migrating-from-modules-to-standalone";
2222
const IONIC_REPOSITORY_ISSUES_URL =
2323
"https://github.com/ionic-team/ionic-angular-standalone-codemods/issues";
24+
const isInteractive = (): boolean =>
25+
TERMINAL_INFO.tty && !TERMINAL_INFO.ci;
2426

2527
async function main() {
2628
console.clear();
@@ -41,7 +43,7 @@ async function main() {
4143
);
4244
log.warning("--------------------------------------------------");
4345

44-
const cli = await group({
46+
const cli = isInteractive() ? await group({
4547
dryRun: () =>
4648
confirm({
4749
message:
@@ -54,7 +56,10 @@ async function main() {
5456
"Please enter the path to your project (default is the current working directory):",
5557
initialValue: cwd(),
5658
}),
57-
});
59+
}) : {
60+
// If we are in a non-interactive terminal then use defaults
61+
dryRun: false, dir: cwd()
62+
};
5863

5964
if (typeof cli.dryRun !== "boolean") {
6065
// User aborted the prompt

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)