@@ -18,7 +18,7 @@ export const KEYBINDINGS = 'keybindings.json';
1818export const SNIPPETS = 'snippets' ;
1919export const LOCAL_SETTINGS = 'local-settings.json' ;
2020
21- export const currentVersion : string = '2.6.2 ' ;
21+ export const currentVersion : string = '2.7.0 ' ;
2222export let vsCodeExtensionDir : string = helpers . getExtensionDir ( ) ;
2323export let codeSyncExtensionDir : string = path . join ( vsCodeExtensionDir , 'golf1052.code-sync-' + currentVersion ) ;
2424
@@ -110,7 +110,9 @@ export class CodeSync {
110110 excluded : {
111111 installed : [ ] ,
112112 external : [ ]
113- }
113+ } ,
114+ executableName : '' ,
115+ settingsPath : ''
114116 } ;
115117 this . Settings . Settings = tmpSettings ;
116118 this . Settings . save ( ) ;
@@ -159,14 +161,14 @@ export class CodeSync {
159161
160162 startFileWatcher = ( ) => {
161163 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 ) ;
164166 }
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 ) ;
167169 }
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 ) ;
170172 }
171173 this . fileWatcher = new FileWatcher ( files , this . Settings ) ;
172174 }
@@ -204,8 +206,10 @@ export class CodeSync {
204206 return ;
205207 }
206208 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 ) ;
209213 }
210214 this . statusBar . reset ( ) ;
211215 this . logger . appendLine ( 'Finished importing settings.' ) ;
@@ -216,13 +220,13 @@ export class CodeSync {
216220 if ( this . Settings . Settings . importSettings ) {
217221 this . logger . appendLine ( 'Exporting settings.' ) ;
218222 this . startSync ( 'Exporting settings' ) ;
219- let settingsPath : string = helpers . getUserSettingsFilePath ( ) ;
223+ let settingsPath : string = helpers . getUserSettingsFilePath ( this . Settings . Settings ) ;
220224 if ( ! fs . existsSync ( settingsPath ) ) {
221225 this . logger . appendLine ( `Could not find settings path at ${ settingsPath } . Giving up.` ) ;
222226 this . statusBar . reset ( ) ;
223227 return ;
224228 }
225- this . localSettingsManager . export ( helpers . getUserSettingsFilePath ( ) , path . join ( this . codeSyncDir , SETTINGS ) ) ;
229+ this . localSettingsManager . export ( settingsPath , path . join ( this . codeSyncDir , SETTINGS ) ) ;
226230 this . statusBar . reset ( ) ;
227231 this . logger . appendLine ( 'Finished exporting settings.' ) ;
228232 }
@@ -239,8 +243,10 @@ export class CodeSync {
239243 return ;
240244 }
241245 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 ) ;
244250 }
245251 this . statusBar . reset ( ) ;
246252 this . logger . appendLine ( 'Finished importing keybindings.' ) ;
@@ -250,10 +256,13 @@ export class CodeSync {
250256 async exportKeybindings ( ) {
251257 if ( this . Settings . Settings . importKeybindings ) {
252258 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 ( ) ;
254263 return ;
255264 }
256- await helpers . copy ( helpers . getKeybindingsFilePath ( ) , path . join ( this . codeSyncDir , KEYBINDINGS ) ) ;
265+ await helpers . copy ( keybindingsPath , path . join ( this . codeSyncDir , KEYBINDINGS ) ) ;
257266 this . statusBar . reset ( ) ;
258267 }
259268 }
@@ -273,7 +282,7 @@ export class CodeSync {
273282 let s = snippetFiles [ i ] ; if ( fs . lstatSync ( path . join ( snippetsDirectory , s ) ) . isFile ( ) ) {
274283 if ( helpers . isFileEmpty ( path . join ( snippetsDirectory , s ) ) == false &&
275284 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 ) ) ;
277286 }
278287 }
279288 }
@@ -285,10 +294,13 @@ export class CodeSync {
285294 async exportSnippets ( ) {
286295 if ( this . Settings . Settings . importSnippets ) {
287296 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 ( ) ;
289301 return ;
290302 }
291- await helpers . copy ( helpers . getSnippetsFolderPath ( ) , path . join ( this . codeSyncDir , SNIPPETS ) ) ;
303+ await helpers . copy ( snippetsFolderPath , path . join ( this . codeSyncDir , SNIPPETS ) ) ;
292304 this . statusBar . reset ( ) ;
293305 }
294306 }
@@ -303,7 +315,7 @@ export class CodeSync {
303315 let installedAny : boolean = false ;
304316 extensions . forEach ( e => {
305317 if ( installedExtensions . filter ( i => i . id == e ) . length == 0 ) {
306- let val = helpers . installExtension ( e ) ;
318+ let val = helpers . installExtension ( e , this . Settings . Settings ) ;
307319 if ( val ) {
308320 installedAny = true ;
309321 }
@@ -518,6 +530,68 @@ export class CodeSync {
518530 }
519531 }
520532
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+
521595 private startSync ( text : string ) {
522596 this . statusBar . StatusBarText = text ;
523597 this . statusBar . setSync ( ) ;
0 commit comments