Skip to content

Commit 3c65e93

Browse files
committed
Add force replace option for language server download
1 parent 83593d2 commit 3c65e93

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

workspaces/ballerina/ballerina-extension/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,7 @@
11861186
"copyVSIX": "copyfiles *.vsix ./vsix",
11871187
"copyVSIXToRoot": "copyfiles -f ./vsix/*.vsix ../../..",
11881188
"download-ls": "node scripts/download-ls.js",
1189+
"download-ls:prerelease": "node scripts/download-ls.js --prerelease --replace",
11891190
"build": "pnpm run compile && pnpm run lint && pnpm run postbuild",
11901191
"rebuild": "pnpm run clean && pnpm run compile && pnpm run postbuild",
11911192
"postbuild": "if [ \"$isPreRelease\" = \"true\" ]; then pnpm run download-ls --prerelease; else pnpm run download-ls; fi && pnpm run copyFonts && pnpm run copyJSLibs && pnpm run package && pnpm run copyVSIX",

workspaces/ballerina/ballerina-extension/scripts/download-ls.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const GITHUB_REPO_URL = 'https://api.github.com/repos/ballerina-platform/balleri
1010

1111
const args = process.argv.slice(2);
1212
const usePrerelease = args.includes('--prerelease') || process.env.isPreRelease === 'true';
13+
const forceReplace = args.includes('--replace');
1314

1415
function checkExistingJar() {
1516
try {
@@ -177,11 +178,16 @@ async function getLatestRelease(usePrerelease) {
177178

178179
async function main() {
179180
try {
180-
if (checkExistingJar()) {
181+
if (!forceReplace && checkExistingJar()) {
181182
process.exit(0);
182183
}
183184

184-
console.log(`Downloading Ballerina language server${usePrerelease ? ' (prerelease)' : ''}...`);
185+
console.log(`Downloading Ballerina language server${usePrerelease ? ' (prerelease)' : ''}${forceReplace ? ' (force replace)' : ''}...`);
186+
187+
if (forceReplace && fs.existsSync(LS_DIR)) {
188+
console.log('Force replace enabled: clearing existing language server directory...');
189+
fs.rmSync(LS_DIR, { recursive: true, force: true });
190+
}
185191

186192
if (!fs.existsSync(LS_DIR)) {
187193
fs.mkdirSync(LS_DIR, { recursive: true });

0 commit comments

Comments
 (0)