diff --git a/.goreleaser.windows.yml b/.goreleaser.windows.yml index b4bfd45..7df4e31 100644 --- a/.goreleaser.windows.yml +++ b/.goreleaser.windows.yml @@ -17,7 +17,7 @@ release: builds: - id: "windows" main: "main.go" - binary: "dreamland.exe" + binary: "dreamland" goos: - windows goarch: diff --git a/npm/index.js b/npm/index.js index 0bf4701..328dd2d 100755 --- a/npm/index.js +++ b/npm/index.js @@ -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; @@ -41,7 +50,7 @@ function parseAssetName() { } async function downloadAndExtractBinary() { - if (binaryExists()) { + if (binaryExists() && versionMatches()) { return; } @@ -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); @@ -117,4 +127,4 @@ async function main() { } } -main(); +main(); \ No newline at end of file diff --git a/npm/package.json b/npm/package.json index 49f62b7..4c34616 100644 --- a/npm/package.json +++ b/npm/package.json @@ -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"