File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,28 @@ for (let i = 0; i < args.length; i++) {
45
45
}
46
46
}
47
47
48
+ function hasPrettierConfig ( targetDir ) {
49
+ const possibleConfigs = [
50
+ ".prettierrc" ,
51
+ ".prettierrc.json" ,
52
+ ".prettierrc.js" ,
53
+ ".prettierrc.yml" ,
54
+ ".prettierrc.yaml" ,
55
+ ".prettierrc.toml" ,
56
+ "prettier.config.js" ,
57
+ ".prettierrc.config.js" ,
58
+ ] ;
59
+
60
+ // Check for Prettier config files
61
+ for ( const config of possibleConfigs ) {
62
+ if ( fs . existsSync ( path . join ( targetDir , config ) ) ) {
63
+ return true ;
64
+ }
65
+ }
66
+
67
+ return false ;
68
+ }
69
+
48
70
async function runPrettier ( targetDir , dryRun ) {
49
71
try {
50
72
// Get Prettier config from this package
@@ -94,7 +116,9 @@ async function runPrettier(targetDir, dryRun) {
94
116
sortTsConfigFile ( tsconfigPath , options ) ;
95
117
96
118
// Run Prettier on all files
97
- await runPrettier ( targetDir , options . dryRun ) ;
119
+ if ( ! hasPrettierConfig ( targetDir ) ) {
120
+ await runPrettier ( targetDir , options . dryRun ) ;
121
+ }
98
122
99
123
if ( options . dryRun ) {
100
124
console . info ( "Dry run completed. No files were modified." ) ;
You can’t perform that action at this time.
0 commit comments