Skip to content

Commit

Permalink
Support VSCode Insiders
Browse files Browse the repository at this point in the history
  • Loading branch information
golf1052 committed Oct 9, 2017
1 parent 862e71f commit af7620e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "code-sync",
"displayName": "CodeSync",
"description": "Sync VSCode extensions using your favorite file synchronization service (OneDrive, Dropbox, Google Drive, etc.)",
"version": "2.4.0",
"version": "2.5.0",
"publisher": "golf1052",
"keywords": [
"sync",
Expand Down
2 changes: 1 addition & 1 deletion src/cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const KEYBINDINGS = 'keybindings.json';
export const SNIPPETS = 'snippets';
export const LOCAL_SETTINGS = 'local-settings.json';

export const currentVersion: string = '2.4.0';
export const currentVersion: string = '2.5.0';
export let vsCodeExtensionDir: string = helpers.getExtensionDir();
export let codeSyncExtensionDir: string = path.join(vsCodeExtensionDir, 'golf1052.code-sync-' + currentVersion);

Expand Down
30 changes: 24 additions & 6 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ let windows: boolean = process.platform == 'win32';
let osx: boolean = process.platform == 'darwin';
let linux: boolean = process.platform == 'linux';

export function isInsiders(): boolean {
// I have no idea if this works for non english :|
return vscode.env.appName.toLowerCase().includes("insider");
}

export function getInstalledExtensions(): vscode.Extension<any>[] {
return vscode.extensions.all.filter(e => {
return e.extensionPath.startsWith(os.homedir());
Expand All @@ -34,19 +39,27 @@ export function getExtensionDir(): string {
return p.dir;
}
else {
return path.join(os.homedir(), '.vscode/extensions');
let extensionsPath: string = '.vscode/extensions';
if (isInsiders()) {
extensionsPath = '.vscode-insiders/extensions';
}
return path.join(os.homedir(), extensionsPath);
}
}

function getCodeSettingsFolderPath(): string {
let codeString = 'Code';
if (isInsiders()) {
codeString = 'Code - Insiders'
}
if (windows) {
return path.join(process.env.APPDATA, 'Code/User/');
return path.join(process.env.APPDATA, `${codeString}/User/`);
}
else if (osx) {
return path.join(os.homedir(), 'Library/Application Support/Code/User/');
return path.join(os.homedir(), `Library/Application Support/${codeString}/User/`);
}
else if (linux) {
return path.join(os.homedir(), '.config/Code/User/');
return path.join(os.homedir(), `.config/${codeString}/User/`);
}
else {
return '';
Expand Down Expand Up @@ -136,11 +149,16 @@ export function logError(err: Error): void {
}

function getCodeCommand(): string {
let codeString: string = 'code';
if (isInsiders()) {
codeString = 'code-insiders';
}

if (windows) {
return 'code.cmd';
return `${codeString}.cmd`;
}
else {
return 'code';
return codeString;
}
}

Expand Down

0 comments on commit af7620e

Please sign in to comment.