Skip to content

Commit a188a4a

Browse files
committed
Made dsc command OS agnostic
Signed-off-by: Seb Julliand <[email protected]>
1 parent 700708b commit a188a4a

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"lint": "eslint .",
3636
"pretest": "npm run lint",
3737
"language:test": "vitest",
38-
"dsc": "mkdir -p dist && npx tsx src/dsc",
38+
"dsc": "npx tsx src/dsc",
3939
"package": "vsce package",
4040
"vscode:prepublish": "rm -rf dist && npm run webpack && npm run dsc",
4141
"webpack": "vscd --clean && webpack --mode development",
@@ -1247,4 +1247,4 @@
12471247
}
12481248
]
12491249
}
1250-
}
1250+
}

src/dsc.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import path from "path";
22

3+
import { existsSync, mkdirSync } from "fs";
4+
import { writeFile } from "fs/promises";
35
import fetch from "node-fetch";
46
import { Octokit } from "octokit";
5-
import { writeFile } from "fs/promises";
67
import { SERVER_VERSION_FILE, SERVER_VERSION_TAG } from "./connection/SCVersion";
78

89
async function work() {
@@ -26,12 +27,15 @@ async function work() {
2627
console.log(`Asset found: ${newAsset.name}`);
2728

2829
const url = newAsset.browser_download_url;
30+
const distDirectory = path.join(`.`, `dist`);
31+
if (!existsSync(distDirectory)) {
32+
mkdirSync(distDirectory);
33+
}
2934

30-
const dist = path.join(`.`, `dist`, SERVER_VERSION_FILE);
31-
32-
await downloadFile(url, dist);
35+
const serverFile = path.join(distDirectory, SERVER_VERSION_FILE);
36+
await downloadFile(url, serverFile);
3337

34-
console.log(`Asset downloaded.`);
38+
console.log(`Asset downloaded: ${serverFile}`);
3539

3640
} else {
3741
console.log(`Release found but no asset found.`);
@@ -45,8 +49,8 @@ async function work() {
4549

4650
function downloadFile(url, outputPath) {
4751
return fetch(url)
48-
.then(x => x.arrayBuffer())
49-
.then(x => writeFile(outputPath, Buffer.from(x)));
52+
.then(x => x.arrayBuffer())
53+
.then(x => writeFile(outputPath, Buffer.from(x)));
5054
}
5155

5256
work();

0 commit comments

Comments
 (0)