@@ -18,7 +18,7 @@ export const KEYBINDINGS = 'keybindings.json';
18
18
export const SNIPPETS = 'snippets' ;
19
19
export const LOCAL_SETTINGS = 'local-settings.json' ;
20
20
21
- export const currentVersion : string = '2.6.2 ' ;
21
+ export const currentVersion : string = '2.7.0 ' ;
22
22
export let vsCodeExtensionDir : string = helpers . getExtensionDir ( ) ;
23
23
export let codeSyncExtensionDir : string = path . join ( vsCodeExtensionDir , 'golf1052.code-sync-' + currentVersion ) ;
24
24
@@ -110,7 +110,9 @@ export class CodeSync {
110
110
excluded : {
111
111
installed : [ ] ,
112
112
external : [ ]
113
- }
113
+ } ,
114
+ executableName : '' ,
115
+ settingsPath : ''
114
116
} ;
115
117
this . Settings . Settings = tmpSettings ;
116
118
this . Settings . save ( ) ;
@@ -159,14 +161,14 @@ export class CodeSync {
159
161
160
162
startFileWatcher = ( ) => {
161
163
let files : any = { } ;
162
- if ( fs . existsSync ( helpers . getUserSettingsFilePath ( ) ) ) {
163
- files [ helpers . getUserSettingsFilePath ( ) ] = this . exportSettings . bind ( this ) ;
164
+ if ( fs . existsSync ( helpers . getUserSettingsFilePath ( this . Settings . Settings ) ) ) {
165
+ files [ helpers . getUserSettingsFilePath ( this . Settings . Settings ) ] = this . exportSettings . bind ( this ) ;
164
166
}
165
- if ( fs . existsSync ( helpers . getKeybindingsFilePath ( ) ) ) {
166
- files [ helpers . getKeybindingsFilePath ( ) ] = this . exportKeybindings . bind ( this ) ;
167
+ if ( fs . existsSync ( helpers . getKeybindingsFilePath ( this . Settings . Settings ) ) ) {
168
+ files [ helpers . getKeybindingsFilePath ( this . Settings . Settings ) ] = this . exportKeybindings . bind ( this ) ;
167
169
}
168
- if ( fs . existsSync ( helpers . getSnippetsFolderPath ( ) ) ) {
169
- files [ helpers . getSnippetsFolderPath ( ) ] = this . exportSnippets . bind ( this ) ;
170
+ if ( fs . existsSync ( helpers . getSnippetsFolderPath ( this . Settings . Settings ) ) ) {
171
+ files [ helpers . getSnippetsFolderPath ( this . Settings . Settings ) ] = this . exportSnippets . bind ( this ) ;
170
172
}
171
173
this . fileWatcher = new FileWatcher ( files , this . Settings ) ;
172
174
}
@@ -204,8 +206,10 @@ export class CodeSync {
204
206
return ;
205
207
}
206
208
if ( helpers . isFileEmpty ( settingsPath ) == false &&
207
- helpers . isFileContentEmpty ( settingsPath ) == false ) {
208
- this . localSettingsManager . import ( settingsPath , helpers . getUserSettingsFilePath ( ) ) ;
209
+ helpers . isFileContentEmpty ( settingsPath ) == false ) {
210
+ const userSettingsFilePath = helpers . getUserSettingsFilePath ( this . Settings . Settings ) ;
211
+ this . logger . appendLine ( `Importing settings to ${ userSettingsFilePath } ` ) ;
212
+ this . localSettingsManager . import ( settingsPath , userSettingsFilePath ) ;
209
213
}
210
214
this . statusBar . reset ( ) ;
211
215
this . logger . appendLine ( 'Finished importing settings.' ) ;
@@ -216,13 +220,13 @@ export class CodeSync {
216
220
if ( this . Settings . Settings . importSettings ) {
217
221
this . logger . appendLine ( 'Exporting settings.' ) ;
218
222
this . startSync ( 'Exporting settings' ) ;
219
- let settingsPath : string = helpers . getUserSettingsFilePath ( ) ;
223
+ let settingsPath : string = helpers . getUserSettingsFilePath ( this . Settings . Settings ) ;
220
224
if ( ! fs . existsSync ( settingsPath ) ) {
221
225
this . logger . appendLine ( `Could not find settings path at ${ settingsPath } . Giving up.` ) ;
222
226
this . statusBar . reset ( ) ;
223
227
return ;
224
228
}
225
- this . localSettingsManager . export ( helpers . getUserSettingsFilePath ( ) , path . join ( this . codeSyncDir , SETTINGS ) ) ;
229
+ this . localSettingsManager . export ( settingsPath , path . join ( this . codeSyncDir , SETTINGS ) ) ;
226
230
this . statusBar . reset ( ) ;
227
231
this . logger . appendLine ( 'Finished exporting settings.' ) ;
228
232
}
@@ -239,8 +243,10 @@ export class CodeSync {
239
243
return ;
240
244
}
241
245
if ( helpers . isFileEmpty ( keybindingsPath ) == false &&
242
- helpers . isFileContentEmpty ( keybindingsPath ) == false ) {
243
- await helpers . copy ( keybindingsPath , helpers . getKeybindingsFilePath ( ) ) ;
246
+ helpers . isFileContentEmpty ( keybindingsPath ) == false ) {
247
+ const keybindingsFilePath = helpers . getKeybindingsFilePath ( this . Settings . Settings )
248
+ this . logger . appendLine ( `Importing keybindings to ${ keybindingsFilePath } ` ) ;
249
+ await helpers . copy ( keybindingsPath , keybindingsFilePath ) ;
244
250
}
245
251
this . statusBar . reset ( ) ;
246
252
this . logger . appendLine ( 'Finished importing keybindings.' ) ;
@@ -250,10 +256,13 @@ export class CodeSync {
250
256
async exportKeybindings ( ) {
251
257
if ( this . Settings . Settings . importKeybindings ) {
252
258
this . startSync ( 'Exporting keybindings' ) ;
253
- if ( ! fs . existsSync ( helpers . getKeybindingsFilePath ( ) ) ) {
259
+ let keybindingsPath = helpers . getKeybindingsFilePath ( this . Settings . Settings ) ;
260
+ if ( ! fs . existsSync ( keybindingsPath ) ) {
261
+ this . logger . appendLine ( `Could not find keybindings path at ${ keybindingsPath } . Giving up.` ) ;
262
+ this . statusBar . reset ( ) ;
254
263
return ;
255
264
}
256
- await helpers . copy ( helpers . getKeybindingsFilePath ( ) , path . join ( this . codeSyncDir , KEYBINDINGS ) ) ;
265
+ await helpers . copy ( keybindingsPath , path . join ( this . codeSyncDir , KEYBINDINGS ) ) ;
257
266
this . statusBar . reset ( ) ;
258
267
}
259
268
}
@@ -273,7 +282,7 @@ export class CodeSync {
273
282
let s = snippetFiles [ i ] ; if ( fs . lstatSync ( path . join ( snippetsDirectory , s ) ) . isFile ( ) ) {
274
283
if ( helpers . isFileEmpty ( path . join ( snippetsDirectory , s ) ) == false &&
275
284
helpers . isFileContentEmpty ( path . join ( snippetsDirectory , s ) ) == false ) {
276
- await helpers . copy ( path . join ( snippetsDirectory , s ) , path . join ( helpers . getSnippetsFolderPath ( ) , s ) ) ;
285
+ await helpers . copy ( path . join ( snippetsDirectory , s ) , path . join ( helpers . getSnippetsFolderPath ( this . Settings . Settings ) , s ) ) ;
277
286
}
278
287
}
279
288
}
@@ -285,10 +294,13 @@ export class CodeSync {
285
294
async exportSnippets ( ) {
286
295
if ( this . Settings . Settings . importSnippets ) {
287
296
this . startSync ( 'Exporting snippets' ) ;
288
- if ( ! fs . existsSync ( helpers . getSnippetsFolderPath ( ) ) ) {
297
+ const snippetsFolderPath = helpers . getSnippetsFolderPath ( this . Settings . Settings ) ;
298
+ if ( ! fs . existsSync ( snippetsFolderPath ) ) {
299
+ this . logger . appendLine ( `Could not find snippets path at ${ snippetsFolderPath } . Giving up.` ) ;
300
+ this . statusBar . reset ( ) ;
289
301
return ;
290
302
}
291
- await helpers . copy ( helpers . getSnippetsFolderPath ( ) , path . join ( this . codeSyncDir , SNIPPETS ) ) ;
303
+ await helpers . copy ( snippetsFolderPath , path . join ( this . codeSyncDir , SNIPPETS ) ) ;
292
304
this . statusBar . reset ( ) ;
293
305
}
294
306
}
@@ -303,7 +315,7 @@ export class CodeSync {
303
315
let installedAny : boolean = false ;
304
316
extensions . forEach ( e => {
305
317
if ( installedExtensions . filter ( i => i . id == e ) . length == 0 ) {
306
- let val = helpers . installExtension ( e ) ;
318
+ let val = helpers . installExtension ( e , this . Settings . Settings ) ;
307
319
if ( val ) {
308
320
installedAny = true ;
309
321
}
@@ -518,6 +530,68 @@ export class CodeSync {
518
530
}
519
531
}
520
532
533
+ async setCodeExecutableName ( ) : Promise < void > {
534
+ let executableName : string = '' ;
535
+ executableName = await vscode . window . showInputBox ( {
536
+ prompt : 'Enter the VSCode executable name. NOTE: Do not include the file extension (.exe, .sh, etc.)' ,
537
+ placeHolder : 'code'
538
+ } ) ;
539
+
540
+ if ( executableName == undefined ) {
541
+ return ;
542
+ } else {
543
+ vscode . window . showInformationMessage ( 'Testing user defined VSCode executable name...' ) ;
544
+ let oldExecutableName ;
545
+ if ( this . Settings . Settings . executableName ) {
546
+ oldExecutableName = this . Settings . Settings . executableName ;
547
+ } else {
548
+ oldExecutableName = '' ;
549
+ }
550
+ let csSettings = this . Settings . Settings ;
551
+ csSettings . executableName = executableName ;
552
+ this . Settings . Settings = csSettings ;
553
+ this . Settings . save ( ) ;
554
+
555
+ if ( helpers . isCodeOnPath ( this . Settings . Settings ) ) {
556
+ vscode . window . showInformationMessage ( `Test succeeded. Will now use ${ executableName } as VSCode executable name.` ) ;
557
+ } else {
558
+ csSettings . executableName = oldExecutableName ;
559
+ this . Settings . Settings = csSettings ;
560
+ this . Settings . save ( ) ;
561
+ vscode . window . showInformationMessage ( 'Test failed. Reverting back to old VSCode executable name.' ) ;
562
+ }
563
+ }
564
+ }
565
+
566
+ async setCodeSettingsPath ( ) : Promise < void > {
567
+ let settingsPath : string = '' ;
568
+ settingsPath = await vscode . window . showInputBox ( {
569
+ prompt : 'Enter the VSCode user settings path. This must be an absolute path.' ,
570
+ placeHolder : helpers . getDefaultCodeSettingsFolderPath ( )
571
+ } ) ;
572
+
573
+ if ( settingsPath == undefined ) {
574
+ return ;
575
+ } else {
576
+ vscode . window . showInformationMessage ( 'Testing user defined VSCode user settings path...' ) ;
577
+ const oldSettingsPath = this . Settings . Settings . settingsPath ;
578
+ this . Settings . Settings . settingsPath = settingsPath ;
579
+ this . Settings . save ( ) ;
580
+
581
+ if ( ! settingsPath ) {
582
+ settingsPath = helpers . getDefaultCodeSettingsFolderPath ( ) ;
583
+ }
584
+
585
+ if ( fs . existsSync ( settingsPath ) ) {
586
+ vscode . window . showInformationMessage ( `Test succeeded. Will now use ${ settingsPath } as VSCode user settings path.` ) ;
587
+ } else {
588
+ this . Settings . Settings . settingsPath = oldSettingsPath ;
589
+ this . Settings . save ( ) ;
590
+ vscode . window . showInformationMessage ( 'Test failed. Reverting back to old VSCode user settings path.' ) ;
591
+ }
592
+ }
593
+ }
594
+
521
595
private startSync ( text : string ) {
522
596
this . statusBar . StatusBarText = text ;
523
597
this . statusBar . setSync ( ) ;
0 commit comments