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

fix(windows): remove the need for admin #74

Merged
merged 6 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Check for new kubo version
id: check
uses: ./.github/actions/check-for-kubo-release
- name: Set up node
if: steps.check.outputs.publish == 'true'
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 14.x
node-version: 20.x
- name: Install
if: steps.check.outputs.publish == 'true'
run: npm install
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-latest, linux-latest]
node-version: [20.x]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 14.x
node-version: ${{ matrix.node-version }}
- run: npm install
- uses: gozala/[email protected]
- run: npm run build --if-present
Expand Down
18 changes: 17 additions & 1 deletion src/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,23 @@ async function link ({ depBin, version }) {
}

console.info('Linking', depBin, 'to', localBin)
fs.symlinkSync(depBin, localBin)
try {
fs.symlinkSync(depBin, localBin)
} catch (err) {
// Try to recover when creating symlink on modern Windows fails (https://github.com/ipfs/npm-kubo/issues/68)
if (isWin && typeof err === 'object' && err !== null && 'code' in err && err.code === 'EPERM') {
console.info('Symlink creation failed due to insufficient privileges. Attempting to copy file instead...')
try {
fs.copyFileSync(depBin, localBin)
console.info('Copying', depBin, 'to', localBin)
} catch (copyErr) {
console.error('File copy also failed:', copyErr)
throw copyErr
}
} else {
throw err
}
}

if (isWin) {
// On Windows, update the shortcut file to use the .exe
Expand Down
4 changes: 2 additions & 2 deletions test/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const test = require('tape-promise').default(require('tape'))
const fs = require('fs-extra')
const os = require('os')
const path= require('path')
const path = require('path')
const { download, downloadAndUpdateBin } = require('../src/download')
const { path: detectLocation } = require('../')
const clean = require('./fixtures/clean')
Expand Down Expand Up @@ -72,7 +72,7 @@ test('Ensure calling download function manually with static values works', async
platform: 'darwin',
arch: 'arm64',
distUrl: 'https://dist.ipfs.tech',
installPath: tempDir,
installPath: tempDir
})
console.log(kuboPath)
const stats = await fs.stat(kuboPath)
Expand Down
Loading