Skip to content

Commit

Permalink
Fix vscdebugger install URL
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelHentschel committed May 25, 2023
1 parent 05a416c commit c0113b3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/installRPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ export interface PackageVersionInfo {
version?: string;
}

export type VersionCheckLevel = 'none'|'required'|'recommended';
type VersionCheckLevel = 'none'|'required'|'recommended';


export async function updateRPackage(extensionPath: string, packageName:string = 'vscDebugger'): Promise<void> {
const url = getRDownloadLink(packageName);
export async function updateRPackage(extensionPath: string): Promise<void> {
const url = getRDownloadLink();
const rPath = (await getRStartupArguments()).path.replace(/^"(.*)"$/, '$1');
const taskDefinition: vscode.TaskDefinition = {
type: 'process'
Expand Down
44 changes: 24 additions & 20 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,20 @@ import path = require('path');
import fs = require('fs');
import winreg = require('winreg');

const packageJson = <{[key: string]: any}>(require('../package.json'));
export interface RPackageInfo {
name: string,
required: string,
recommended: string,
warnIfNewer: string
}

export interface PackageJson {
[key: string]: any
rPackageInfo: RPackageInfo
version: string
}

const packageJson = <PackageJson>(require('../package.json'));

export function config(onlyDebugger: boolean = true): vscode.WorkspaceConfiguration {
if(onlyDebugger){
Expand Down Expand Up @@ -148,19 +161,21 @@ export async function getRStartupArguments(launchConfig: {
}


export function getRDownloadLink(packageName: string): string{
export function getRDownloadLink(): string{
let url: string = config().get<string>('packageURL', '');

if(url === ''){
const platform: string = process.platform;
const version: string = String(packageJson.version); // e.g. "0.1.2"
const platform = process.platform;
const extensionVersion = packageJson.version;
const rPackageVersion = packageJson.rPackageInfo.recommended; // e.g. "0.1.2"
const rPackageName = packageJson.rPackageInfo.name;
const urlBase =
'https://github.com/ManuelHentschel/VSCode-R-Debugger/releases/download/v' +
version +
extensionVersion +
'/' +
packageName +
rPackageName +
'_' +
version;
rPackageVersion;

if(platform === 'win32'){
url = urlBase + '.zip';
Expand All @@ -181,19 +196,8 @@ export function escapeForRegex(text: string): string {
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
}

export interface RequiredRPackageVersion {
name?: string,
required?: string,
recommended?: string,
warnIfNewer?: string
}

export function getRequiredRPackageVersion(): RequiredRPackageVersion {
if(typeof packageJson.rPackageInfo === 'object'){
return <RequiredRPackageVersion>packageJson.rPackageInfo;
} else{
return {};
}
export function getRequiredRPackageVersion(): RPackageInfo {
return packageJson.rPackageInfo;
}


Expand Down

0 comments on commit c0113b3

Please sign in to comment.