File tree 5 files changed +67
-4
lines changed
5 files changed +67
-4
lines changed Original file line number Diff line number Diff line change
1
+ var packageName = 'atom-typescript' ;
2
+ function getConfig ( name ) {
3
+ return atom . config . get ( packageName + '.' + name ) ;
4
+ }
5
+ var Config = ( function ( ) {
6
+ function Config ( ) {
7
+ this . schema = {
8
+ compileOnSave : {
9
+ title : 'Compile on save' ,
10
+ type : 'boolean' ,
11
+ default : true
12
+ }
13
+ } ;
14
+ }
15
+ Object . defineProperty ( Config . prototype , "compileOnSave" , {
16
+ get : function ( ) {
17
+ return getConfig ( 'compileOnSave' ) ;
18
+ } ,
19
+ enumerable : true ,
20
+ configurable : true
21
+ } ) ;
22
+ return Config ;
23
+ } ) ( ) ;
24
+ var config = new Config ( ) ;
25
+ module . exports = config ;
Original file line number Diff line number Diff line change
1
+ ///ts:ref=globals
2
+ /// <reference path="../../globals.ts"/> ///ts:ref:generated
3
+
4
+ // Documentation https://atom.io/docs/api/v0.177.0/Config and http://json-schema.org/examples.html
5
+ // To add a new setting you need to add to
6
+ // schema
7
+ // getter/setter
8
+
9
+ var packageName = 'atom-typescript' ;
10
+ function getConfig < T > ( name : string ) : T {
11
+ return atom . config . get ( packageName + '.' + name ) ;
12
+ }
13
+
14
+ class Config {
15
+ schema = {
16
+ compileOnSave : {
17
+ title : 'Compile on save' ,
18
+ type : 'boolean' ,
19
+ default : true
20
+ }
21
+ }
22
+ get compileOnSave ( ) { return getConfig < boolean > ( 'compileOnSave' ) }
23
+ }
24
+ var config = new Config ( ) ;
25
+ export = config ;
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ var statusBarMessage;
10
10
var editorWatch ;
11
11
var autoCompleteWatch ;
12
12
var parent = require ( '../worker/parent' ) ;
13
+ var atomConfig = require ( './atom/atomConfig' ) ;
14
+ exports . config = atomConfig . schema ;
13
15
function activate ( state ) {
14
16
var linter = apd . require ( 'linter' ) ;
15
17
var acp = apd . require ( 'autocomplete-plus' ) ;
@@ -45,7 +47,10 @@ function activate(state) {
45
47
} ) ;
46
48
var saveObserver = editor . onDidSave ( function ( event ) {
47
49
onDisk = true ;
48
- parent . updateText ( { filePath : filePath , text : editor . getText ( ) } ) . then ( function ( ) { return parent . emitFile ( { filePath : filePath } ) ; } ) . then ( function ( res ) { return errorView . showEmittedMessage ( res ) ; } ) ;
50
+ var textUpdated = parent . updateText ( { filePath : filePath , text : editor . getText ( ) } ) ;
51
+ if ( atomConfig . compileOnSave ) {
52
+ textUpdated . then ( function ( ) { return parent . emitFile ( { filePath : filePath } ) ; } ) . then ( function ( res ) { return errorView . showEmittedMessage ( res ) ; } ) ;
53
+ }
49
54
} ) ;
50
55
var destroyObserver = editor . onDidDestroy ( function ( ) {
51
56
errorView . setErrors ( filePath , [ ] ) ;
Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ export interface PackageState {
31
31
32
32
import parent = require( '../worker/parent' ) ;
33
33
34
+ // Export config
35
+ import atomConfig = require( './atom/atomConfig' ) ;
36
+ export var config = atomConfig . schema ;
37
+
34
38
export function activate ( state : PackageState ) {
35
39
36
40
// Don't activate if we have a dependency that isn't available
@@ -121,9 +125,12 @@ export function activate(state: PackageState) {
121
125
onDisk = true ;
122
126
123
127
// TODO: store by file path
124
- parent . updateText ( { filePath : filePath , text : editor . getText ( ) } )
125
- . then ( ( ) => parent . emitFile ( { filePath } ) )
126
- . then ( ( res ) => errorView . showEmittedMessage ( res ) ) ;
128
+ var textUpdated = parent . updateText ( { filePath : filePath , text : editor . getText ( ) } ) ;
129
+
130
+ if ( atomConfig . compileOnSave ) {
131
+ textUpdated . then ( ( ) => parent . emitFile ( { filePath } ) )
132
+ . then ( ( res ) => errorView . showEmittedMessage ( res ) ) ;
133
+ }
127
134
} ) ;
128
135
129
136
// Observe editors closing
Original file line number Diff line number Diff line change 14
14
"files" : [
15
15
" ./globals.ts" ,
16
16
" ./linter.ts" ,
17
+ " ./main/atom/atomConfig.ts" ,
17
18
" ./main/atom/atomUtils.ts" ,
18
19
" ./main/atom/autoCompleteProvider.ts" ,
19
20
" ./main/atom/buildView.ts" ,
You can’t perform that action at this time.
0 commit comments