Skip to content

Commit 9d08ffb

Browse files
committed
chore(cli): bump version to 0.0.19 and enhance prettier configuration handling
- Updated package version to 0.0.19. - Improved prettier configuration handling by checking for the existence of the .prettierrc file before applying settings.
1 parent c59a697 commit 9d08ffb

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

packages/cli/lib/codegen/ast/inject-config.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { join } from "path";
2-
import { format, resolveConfig, resolveConfigFile } from "prettier";
2+
import { format, Options, resolveConfig, resolveConfigFile } from "prettier";
33
import {
44
Project,
55
SourceFile,
66
SyntaxKind,
77
ObjectLiteralExpression,
88
Node,
99
} from "ts-morph";
10+
import { pathExists } from "fs-extra/esm";
1011

1112
export class InjectConfig {
1213
private project: Project;
@@ -146,13 +147,16 @@ export class InjectConfig {
146147
const updatedText = objects.getText().replace(/,\s*,/g, ",");
147148
objects.replaceWithText(updatedText);
148149

149-
const prettierConfig = await resolveConfig(this.projectRoot, {
150-
config: join(this.projectRoot, ".prettierrc"),
151-
});
150+
let prettierConfig = null;
151+
if (await pathExists(join(this.projectRoot, ".prettierrc"))) {
152+
prettierConfig = await resolveConfig(this.projectRoot, {
153+
config: join(this.projectRoot, ".prettierrc"),
154+
});
155+
}
152156

153157
const formatted = await format(this.sourceFile.getFullText(), {
154158
parser: "typescript",
155-
...prettierConfig,
159+
...(prettierConfig || {}),
156160
});
157161

158162
this.sourceFile.replaceWithText(formatted);

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@intentjs/cli",
3-
"version": "0.0.18",
3+
"version": "0.0.19",
44
"description": "Helper commands for building Intent application.",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)