File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { formatDockerfileContents } from '@reteps/dockerfmt'
21import type { Parser , ParserOptions , Plugin , Printer } from 'prettier'
32import {
43 type File ,
@@ -94,6 +93,18 @@ const dockerfileParser: Parser<string> = {
9493 locEnd : node => node . length ,
9594}
9695
96+ let formatDockerfileContents_ :
97+ | typeof import ( '@reteps/dockerfmt' ) . formatDockerfileContents
98+ | undefined
99+
100+ const getFormatDockerfileContents = async ( ) => {
101+ if ( ! formatDockerfileContents_ ) {
102+ const dockerfmt = await import ( '@reteps/dockerfmt' )
103+ formatDockerfileContents_ = dockerfmt . formatDockerfileContents
104+ }
105+ return formatDockerfileContents_
106+ }
107+
97108const dockerPrinter : Printer < string > = {
98109 // @ts -expect-error -- https://github.com/prettier/prettier/issues/15080#issuecomment-1630987744
99110 async print (
@@ -108,6 +119,7 @@ const dockerPrinter: Printer<string> = {
108119 if ( ! node ) {
109120 return ''
110121 }
122+ const formatDockerfileContents = await getFormatDockerfileContents ( )
111123 return formatDockerfileContents ( node , {
112124 indent,
113125 trailingNewline : true ,
@@ -204,6 +216,7 @@ const shPrinter: Printer<Node | string> = {
204216 }
205217
206218 try {
219+ const formatDockerfileContents = await getFormatDockerfileContents ( )
207220 return await formatDockerfileContents ( node , {
208221 indent,
209222 trailingNewline : true ,
You can’t perform that action at this time.
0 commit comments