Skip to content

Commit 9ceb76d

Browse files
committed
Added formatOnSave tsconfig property
1 parent a6b2dbe commit 9ceb76d

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

dist/main/atom/onSaveHandler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function handle(event) {
2727
if (fileDetails.project.buildOnSave) {
2828
atom.commands.dispatch(atom.views.getView(event.editor), 'typescript:build');
2929
}
30-
if (true) {
30+
if (fileDetails.project.atom.formatOnSave) {
3131
atom.commands.dispatch(atom.views.getView(event.editor), 'typescript:format-code');
3232
}
3333
});

dist/main/tsconfig/tsconfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ function getDefaultInMemoryProject(srcFile) {
181181
compileOnSave: true,
182182
buildOnSave: false,
183183
scripts: {},
184-
atom: { rewriteTsconfig: true },
184+
atom: { rewriteTsconfig: true, formatOnSave: false },
185185
};
186186
return {
187187
projectFileDirectory: dir,
@@ -253,7 +253,7 @@ function getProjectSync(pathOrSrcFile) {
253253
externalTranspiler: projectSpec.externalTranspiler == undefined ? undefined : projectSpec.externalTranspiler,
254254
scripts: projectSpec.scripts || {},
255255
buildOnSave: !!projectSpec.buildOnSave,
256-
atom: { rewriteTsconfig: true }
256+
atom: { rewriteTsconfig: true, formatOnSave: false }
257257
};
258258
var validationResult = validator.validate(projectSpec.compilerOptions);
259259
if (validationResult.errorMessage) {

lib/main/atom/onSaveHandler.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ export function handle(event: { filePath: string; editor: AtomCore.IEditor }) {
5353
'typescript:build');
5454
}
5555

56-
if(true){
57-
atom.commands.dispatch(
58-
atom.views.getView(event.editor),
59-
'typescript:format-code');
56+
if (fileDetails.project.atom.formatOnSave) {
57+
atom.commands.dispatch(
58+
atom.views.getView(event.editor),
59+
'typescript:format-code');
6060
}
6161

6262
});

lib/main/tsconfig/tsconfig.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ interface TypeScriptProjectRawSpecification {
139139
buildOnSave?: boolean;
140140
externalTranspiler?: string | { name: string; options?: any };
141141
scripts?: { postbuild?: string };
142-
atom?: { rewriteTsconfig?: boolean };
142+
atom?: { rewriteTsconfig?: boolean, formatOnSave?: boolean };
143143
}
144144

145145
/**
@@ -157,7 +157,7 @@ export interface TypeScriptProjectSpecification {
157157
package?: UsefulFromPackageJson;
158158
externalTranspiler?: string | { name: string; options?: any };
159159
scripts: { postbuild?: string };
160-
atom: { rewriteTsconfig: boolean };
160+
atom: { rewriteTsconfig: boolean, formatOnSave: boolean };
161161
}
162162

163163
///////// FOR USE WITH THE API /////////////
@@ -350,7 +350,7 @@ export function getDefaultInMemoryProject(srcFile: string): TypeScriptProjectFil
350350
compileOnSave: true,
351351
buildOnSave: false,
352352
scripts: {},
353-
atom: { rewriteTsconfig: true },
353+
atom: { rewriteTsconfig: true, formatOnSave: false },
354354
};
355355

356356
return {
@@ -442,7 +442,7 @@ export function getProjectSync(pathOrSrcFile: string): TypeScriptProjectFileDeta
442442
externalTranspiler: projectSpec.externalTranspiler == undefined ? undefined : projectSpec.externalTranspiler,
443443
scripts: projectSpec.scripts || {},
444444
buildOnSave: !!projectSpec.buildOnSave,
445-
atom: { rewriteTsconfig: true }
445+
atom: { rewriteTsconfig: true, formatOnSave: false }
446446
};
447447

448448
// Validate the raw compiler options before converting them to TS compiler options

0 commit comments

Comments
 (0)