Skip to content

Commit

Permalink
fix: can handle v prefix in the GH release name
Browse files Browse the repository at this point in the history
Ref: arduino/arduino-cli#2374

Signed-off-by: dankeboy36 <dankeboy36@gmail.com>
  • Loading branch information
dankeboy36 committed Dec 6, 2023
1 parent c2835b1 commit 812287f
Show file tree
Hide file tree
Showing 4 changed files with 201 additions and 10 deletions.
197 changes: 192 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "install-from-gh-to-vscode",
"version": "0.1.0-beta.8",
"version": "0.1.0-beta.9",
"description": "Lib for VS Code extensions installing executables from GitHub",
"main": "out/src/index.js",
"types": "out/src/index.d.ts",
Expand All @@ -27,7 +27,8 @@
"test": "tsc -p ./ && tape -r source-map-support/register 'out/test/**/*.js' | tap-spec",
"format": "clang-format -i --glob=\"{src,test}/**/*.ts\"",
"git-clang-format": "git-clang-format",
"prepare": "npm run test && npm run format && tsc -p ./"
"prepare": "npm run test && npm run format && tsc -p ./",
"example": "ts-node ./src/example/index.ts"
},
"dependencies": {
"abort-controller": "^3.0.0",
Expand Down Expand Up @@ -58,6 +59,7 @@
"tap-spec": "^5.0.0",
"tape": "^5.0.0",
"tmp-promise": "^2.1.0",
"ts-node": "^10.9.1",
"typescript": "^3.8.3"
}
}
5 changes: 3 additions & 2 deletions src/example/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ class Noop implements UI {

const arduinoCliOptions: Options = {
// pinned version range
versionRange: '<=0.27.0',
versionRange: '<=v0.35.0-rc.7',
gh: {owner: 'arduino', repo: 'arduino-cli'},
executableName: 'arduino-cli',
versionFlags: ['version', '--format', 'json'],
parseVersion(output: string):
string { return JSON.parse(output.trim()).VersionString; },
async pickAsset(assetNames: string[]): Promise<number> {
return 6; // 'arduino-cli_0.27.0_macOS_64bit.tar.gz'
// console.log(assetNames[7]); // arduino-cli_0.35.0-rc.7_macOS_64bit.tar.gz
return 7;
}
};

Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ async function latestCompatibleVersion(ui: UI): Promise<string|undefined> {
.reverse();
for (const tag of tags) {
if (versionConstrains.test(tag)) {
return tag.version;
return tag.raw; // use the raw semver string
// https://github.com/arduino/arduino-cli/pull/2374
}
}
throw new Error(`Could not find a compatible version for ${
Expand Down

0 comments on commit 812287f

Please sign in to comment.