Skip to content

Commit

Permalink
updated build for mac and windows + npm wrapper now tracks the version
Browse files Browse the repository at this point in the history
  • Loading branch information
samyfodil committed May 15, 2024
1 parent d730c99 commit fa6e426
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ release:
builds:
- id: "windows"
main: "main.go"
binary: "dreamland.exe"
binary: "dreamland"
goos:
- windows
goarch:
Expand Down
14 changes: 12 additions & 2 deletions npm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,21 @@ const packageJson = require("./package.json");

const binaryDir = path.join(__dirname, "bin");
const binaryPath = path.join(binaryDir, "dreamland");
const versionFilePath = path.join(binaryDir, "version.txt");
const packageVersion = packageJson.dream;

function binaryExists() {
return fs.existsSync(binaryPath);
}

function versionMatches() {
if (!fs.existsSync(versionFilePath)) {
return false;
}
const installedVersion = fs.readFileSync(versionFilePath, "utf-8").trim();
return installedVersion === packageVersion;
}

function parseAssetName() {
let os, arch;

Expand All @@ -41,7 +50,7 @@ function parseAssetName() {
}

async function downloadAndExtractBinary() {
if (binaryExists()) {
if (binaryExists() && versionMatches()) {
return;
}

Expand Down Expand Up @@ -84,6 +93,7 @@ async function downloadAndExtractBinary() {
C: binaryDir,
});
fs.unlinkSync(tarPath); // Remove the tarball after extraction
fs.writeFileSync(versionFilePath, version); // Save the version to a file
resolve();
});
writer.on("error", reject);
Expand Down Expand Up @@ -117,4 +127,4 @@ async function main() {
}
}

main();
main();
4 changes: 2 additions & 2 deletions npm/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@taubyte/dream",
"version": "0.1.5",
"dream": "1.0.4",
"version": "0.1.6",
"dream": "1.0.5",
"description": "Node wrapper for taubyte/dreamland",
"bin": {
"dream": "./index.js"
Expand Down

0 comments on commit fa6e426

Please sign in to comment.