File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -68,13 +68,15 @@ export class DtsContent {
6868 return path . join ( this . rootDir , this . searchDir , this . rInputPath ) ;
6969 }
7070
71- public async writeFile ( ) : Promise < void > {
71+ public async writeFile ( postprocessor = ( formatted : string ) => formatted ) : Promise < void > {
72+ const finalOutput = postprocessor ( this . formatted ) ;
73+
7274 const outPathDir = path . dirname ( this . outputFilePath ) ;
7375 if ( ! isThere ( outPathDir ) ) {
7476 mkdirp . sync ( outPathDir ) ;
7577 }
7678
77- await writeFile ( this . outputFilePath , this . formatted , 'utf8' ) ;
79+ await writeFile ( this . outputFilePath , finalOutput , 'utf8' ) ;
7880 }
7981}
8082
Original file line number Diff line number Diff line change @@ -180,6 +180,19 @@ export = styles;
180180 } ) ;
181181
182182 describe ( '#writeFile' , ( ) => {
183+ it ( 'accepts a postprocessor function' , done => {
184+ new DtsCreator ( )
185+ . create ( 'test/testStyle.css' )
186+ . then ( content => {
187+ return content . writeFile (
188+ formatted => `// this banner was added to the .d.ts file automatically.\n${ formatted } `
189+ ) ;
190+ } )
191+ . then ( ( ) => {
192+ done ( ) ;
193+ } ) ;
194+ } ) ;
195+
183196 it ( 'writes a file' , done => {
184197 new DtsCreator ( )
185198 . create ( 'test/testStyle.css' )
You can’t perform that action at this time.
0 commit comments