@@ -39,20 +39,21 @@ export default function createPrettierLoader(options: PrettierLoaderOptions): IL
3939 } ;
4040
4141 try {
42+ // format with prettier
4243 const result = await prettier . format ( data , config ) ;
4344 return result ;
4445 } catch ( error ) {
4546 if ( error instanceof Error && error . message . startsWith ( "Cannot find package" ) ) {
4647 console . log ( ) ;
47- console . log ( "Prettier is missing some dependecies - installing all project dependencies" ) ;
48+ console . log ( "⚠️ Prettier plugins are not installed. Formatting without plugins." ) ;
49+ console . log ( "⚠️ To use prettier plugins install project dependencies before running Lingo.dev." ) ;
4850
49- // prettier is missing dependencies - install all project dependencies
50- installDependencies ( ) ;
51+ config . plugins = [ ] ;
5152
52- // clear file system structure cache to find newly installed dependencies
53+ // clear file system structure cache
5354 await prettier . clearConfigCache ( ) ;
5455
55- // try to format again
56+ // format again without plugins
5657 const result = await prettier . format ( data , config ) ;
5758 return result ;
5859 } else {
@@ -71,31 +72,3 @@ async function loadPrettierConfig(filePath: string) {
7172 return { } ;
7273 }
7374}
74-
75- // install all dependencies using package manager
76- async function installDependencies ( ) {
77- const packageManager = await getPackageManager ( ) ;
78- console . log ( `Installing dependencies using ${ packageManager } ` ) ;
79- execSync ( `${ packageManager } install --frozen-lockfile` , { stdio : "inherit" } ) ;
80- console . log ( `Dependencies installed` ) ;
81- }
82-
83- // determine if yarn or pnpm is used based on lockfile, otherwise use npm
84- async function getPackageManager ( ) {
85- const yarnLockfile = path . resolve ( process . cwd ( ) , "yarn.lock" ) ;
86- if ( fs . existsSync ( yarnLockfile ) ) {
87- return "yarn" ;
88- }
89-
90- const pnpmLockfile = path . resolve ( process . cwd ( ) , "pnpm-lock.yaml" ) ;
91- if ( fs . existsSync ( pnpmLockfile ) ) {
92- return "pnpm" ;
93- }
94-
95- const bunLockfile = path . resolve ( process . cwd ( ) , "bun.lock" ) ;
96- if ( fs . existsSync ( bunLockfile ) ) {
97- return "bun" ;
98- }
99-
100- return "npm" ;
101- }
0 commit comments