Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: cleanup env names after rename #65

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ An error will be thrown if the path to the binary cannot be resolved.

### Caching

Downloaded archives are placed in OS-specific cache directory which can be customized by setting `NPM_GO_IPFS_CACHE` in env.
Downloaded archives are placed in OS-specific cache directory which can be customized by setting `NPM_KUBO_CACHE` in env.

### Overriding with `KUBO_BINARY` env

Expand Down
4 changes: 2 additions & 2 deletions src/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const isWin = process.platform === 'win32'
* @param {string} url
*/
async function cachingFetchAndVerify (url) {
const cacheDir = process.env.NPM_GO_IPFS_CACHE || cachedir('npm-kubo')
const cacheDir = process.env.NPM_KUBO_CACHE || process.env.NPM_GO_IPFS_CACHE || cachedir('npm-kubo')
const filename = url.split('/').pop()

if (!filename) {
Expand Down Expand Up @@ -124,7 +124,7 @@ function cleanArguments (version, platform, arch, installPath) {
version: process.env.TARGET_VERSION || version || conf.version,
platform: process.env.TARGET_OS || platform || goenv.GOOS,
arch: process.env.TARGET_ARCH || arch || goenv.GOARCH,
distUrl: process.env.GO_IPFS_DIST_URL || conf.distUrl,
distUrl: process.env.KUBO_DIST_URL || process.env.GO_IPFS_DIST_URL || conf.distUrl,
installPath: installPath ? path.resolve(installPath) : process.cwd()
}
}
Expand Down
15 changes: 14 additions & 1 deletion test/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,19 @@ test('Returns an error when version unsupported', async (t) => {
t.end()
})

test('Returns an error when dist url is 404', async (t) => {
test('Returns an error when KUBO_DIST_URL is 404', async (t) => {
await clean()

process.env.KUBO_DIST_URL = 'https://dist.ipfs.tech/notfound'

await t.rejects(download(), /404/)

delete process.env.KUBO_DIST_URL

t.end()
})

test('Returns an error when legacy GO_IPFS_DIST_URL is 404', async (t) => {
await clean()

process.env.GO_IPFS_DIST_URL = 'https://dist.ipfs.tech/notfound'
Expand All @@ -38,6 +50,7 @@ test('Returns an error when dist url is 404', async (t) => {
t.end()
})


test('Path returns undefined when no binary has been downloaded', async (t) => {
await clean()

Expand Down