1
1
import * as ts from "typescript" ;
2
- import formatter from "./formatter" ;
2
+ import { format } from "./formatter" ;
3
3
import { createDefaultFormatCodeSettings , parseJSON } from "./utils" ;
4
4
5
5
export { parseJSON } ;
6
6
7
7
import * as fs from "fs" ;
8
8
import * as path from "path" ;
9
9
10
- import base from "./provider/base" ;
11
- import tsconfigjson from "./provider/tsconfigjson" ;
12
- import editorconfig , { postProcess as editorconfigPostProcess } from "./provider/editorconfig" ;
13
- import tslintjson , { postProcess as tslintPostProcess } from "./provider/tslintjson" ;
14
- import vscodesettings from "./provider/vscodesettings" ;
10
+ import * as base from "./provider/base" ;
11
+ import * as tsconfigjson from "./provider/tsconfigjson" ;
12
+ import * as editorconfig from "./provider/editorconfig" ;
13
+ import * as tslintjson from "./provider/tslintjson" ;
14
+ import * as vscodesettings from "./provider/vscodesettings" ;
15
15
16
16
const packageJson = JSON . parse ( fs . readFileSync ( path . join ( __dirname , "../package.json" ) ) . toString ( ) ) ;
17
17
export const version = packageJson . version ;
@@ -144,21 +144,21 @@ export function processString(fileName: string, content: string, opts: Options):
144
144
145
145
let processor = new Processor ( ) ;
146
146
if ( opts . tsfmt ) {
147
- processor . addOptionModify ( base ) ;
147
+ processor . addOptionModify ( base . makeFormatCodeOptions ) ;
148
148
}
149
149
if ( opts . tsconfig ) {
150
- processor . addOptionModify ( tsconfigjson ) ;
150
+ processor . addOptionModify ( tsconfigjson . makeFormatCodeOptions ) ;
151
151
}
152
152
if ( opts . editorconfig ) {
153
- processor . addOptionModify ( editorconfig ) ;
154
- processor . addPostProcess ( editorconfigPostProcess ) ;
153
+ processor . addOptionModify ( editorconfig . makeFormatCodeOptions ) ;
154
+ processor . addPostProcess ( editorconfig . postProcess ) ;
155
155
}
156
156
if ( opts . tslint ) {
157
- processor . addOptionModify ( tslintjson ) ;
158
- processor . addPostProcess ( tslintPostProcess ) ;
157
+ processor . addOptionModify ( tslintjson . makeFormatCodeOptions ) ;
158
+ processor . addPostProcess ( tslintjson . postProcess ) ;
159
159
}
160
160
if ( opts . vscode ) {
161
- processor . addOptionModify ( vscodesettings ) ;
161
+ processor . addOptionModify ( vscodesettings . makeFormatCodeOptions ) ;
162
162
}
163
163
processor . addPostProcess ( ( _fileName : string , formattedCode : string , _opts : Options , formatSettings : ts . FormatCodeSettings ) => {
164
164
// replace newline code. maybe NewLineCharacter params affect to only "new" newline by language service.
@@ -169,7 +169,7 @@ export function processString(fileName: string, content: string, opts: Options):
169
169
let formatSettings = createDefaultFormatCodeSettings ( ) ;
170
170
return processor . processFormatCodeOptions ( fileName , opts , formatSettings )
171
171
. then ( formatSettings => {
172
- let formattedCode = formatter ( fileName , content , formatSettings ) ;
172
+ let formattedCode = format ( fileName , content , formatSettings ) ;
173
173
174
174
// apply post process logic
175
175
return processor . postProcess ( fileName , formattedCode , opts , formatSettings ) ;
0 commit comments