Skip to content

Commit

Permalink
Fix bug "No parser and no filepath given" on prettierApply
Browse files Browse the repository at this point in the history
* fix bug "No parser and no filepath given" on prettierApply
    * if a valid `.prettierrc' file is not found, pretterApply function not work
  • Loading branch information
imjuni committed Aug 24, 2022
1 parent abb6db6 commit 6e45f34
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ctix",
"version": "1.3.2",
"version": "1.3.3",
"description": "Automatic create index.ts file",
"scripts": {
"test": "cross-env NODE_ENV=develop DEBUG=ctix:* jest --runInBand",
Expand Down
6 changes: 4 additions & 2 deletions src/writes/prettierApply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import prettier from 'prettier';

export default async function prettierApply(project: string, contents: string) {
try {
const option = await prettier.resolveConfig(project, { editorconfig: true });
const option = await prettier.resolveConfig(project, {
editorconfig: true,
});

if (isNotEmpty(option)) {
if (isNotEmpty(option) && option.parser === 'typescript') {
const prettiered = prettier.format(contents, option);
return { apply: true, contents: prettiered };
}
Expand Down

0 comments on commit 6e45f34

Please sign in to comment.