diff --git a/package.json b/package.json index 26d7e52..04ad7c9 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,6 @@ }, "dependencies": { "cachedir": "^2.3.0", - "go-platform": "^1.0.0", "got": "^11.7.0", "gunzip-maybe": "^1.4.2", "hasha": "^5.2.2", diff --git a/src/download.js b/src/download.js index ffb50d1..eec24ca 100644 --- a/src/download.js +++ b/src/download.js @@ -13,8 +13,7 @@ go-ipfs architecture: the architecture of the hardware this program is run from go-ipfs install path: './go-ipfs' */ -// @ts-ignore no types -const goenv = require('go-platform') +const goenv = require('./go-platform') const gunzip = require('gunzip-maybe') const got = require('got').default const path = require('path') diff --git a/src/go-platform.js b/src/go-platform.js new file mode 100644 index 0000000..a600766 --- /dev/null +++ b/src/go-platform.js @@ -0,0 +1,33 @@ +'use strict' + +function getGoOs () { + switch (process.platform) { + case "sunos": + return "solaris" + case "win32": + return "windows" + } + + return process.platform +} + +function getGoArch () { + switch (process.arch) { + case "ia32": + return "386" + case "x64": + return "amd64" + case "arm": + return "arm" + case "arm64": + return "arm64" + } + + return process.arch +} + + +module.exports = { + GOOS: getGoOs(), + GOARCH: getGoArch() +}