Skip to content

Commit

Permalink
fix: Create symlink properly when installed globally
Browse files Browse the repository at this point in the history
  • Loading branch information
prantlf committed Oct 26, 2023
1 parent 4d06113 commit 60f7861
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
cache: 'pnpm'
registry-url: 'https://registry.npmjs.org'
- name: Install Dependencies
run: pnpm i --frozen-lockfile --no-verify-store-integrity
run: 'DEBUG=* pnpm i --frozen-lockfile --no-verify-store-integrity'
- name: Publish
if: ${{ github.ref_name == 'master' }}
uses: cycjimmy/semantic-release-action@v4
Expand Down
15 changes: 12 additions & 3 deletions install.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,21 @@ const platformSuffixes = {
}

try {
const { INIT_CWD: root } = process.env
if (!root) throw new Error('not running during npm install')
if (!process.env.INIT_CWD) throw new Error('not running during npm install')

// installed locally
let bin = join(__dirname, '..', 'node_modules', '.bin')
// installed globally
if (!await exists(bin)) bin = join(__dirname, '..', '..', 'bin')
// installed dependencies of this package
if (!await exists(bin)) bin = join(__dirname, 'node_modules', '.bin')
if (!await exists(bin)) throw new Error('cannot find bin directory')

const { executable, version } = await grab(
{ repository, platformSuffixes, targetDirectory: __dirname, unpackExecutable: true })
console.log('downloaded and unpacked "%s" version %s', executable, version)
const link = join(root, 'node_modules', '.bin', basename(executable))

const link = join(bin, basename(executable))
if (await exists(link)) {
log('unlink "%s"', link)
await unlink(link)
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"denolint": "2.0.14"
},
"keywords": [
"changes",
"changes",
"changelog",
"generate",
Expand Down

0 comments on commit 60f7861

Please sign in to comment.