Skip to content
This repository was archived by the owner on Sep 17, 2023. It is now read-only.

Commit d6281f5

Browse files
committed
fix: symlink downloaded binary into node_modules/.bin
Ticket: #4
1 parent f8bfcf3 commit d6281f5

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

npm/install.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1-
// const fs = require('fs')
2-
// const path = require('path')
1+
const fs = require('fs')
2+
const path = require('path')
33
const getBinary = require('./get-binary')
44

5+
const binaryName = 'monorepo'
6+
const repoDir = path.dirname(__dirname)
7+
const downloadDir = path.resolve(repoDir, 'bin')
8+
const scopedPackageDir = path.dirname(repoDir)
9+
const nodeModulesDir = path.dirname(scopedPackageDir)
10+
511
// Link the downloaded binary into the node_modules/.bin directory
6-
// const linkBinaryIntoBin = () => {
7-
// const binaryName = 'monorepo'
8-
// const existingPath = path.resolve(__dirname, `../node_modules/binary-install/bin/${binaryName}`)
9-
// const desiredPath = path.resolve(__dirname, `../node_modules/.bin/${binaryName}`)
10-
//
11-
// // Only symlink the path when it does not yet exist
12-
// if (!fs.existsSync(desiredPath)) {
13-
// fs.linkSync(existingPath, desiredPath)
14-
// }
15-
// }
12+
const linkBinaryIntoBin = () => {
13+
const existingPath = path.resolve(downloadDir, binaryName)
14+
const desiredPath = path.resolve(nodeModulesDir, '.bin', binaryName)
15+
16+
// Only symlink the path when it does not yet exist
17+
if (!fs.existsSync(desiredPath)) {
18+
fs.linkSync(existingPath, desiredPath)
19+
}
20+
}
1621

17-
// Downloaded binary to /node_modules/binary-install/bin/{ name }
22+
// Downloaded binary to /bin/{ name }
1823
getBinary().install()
19-
// .then(linkBinaryIntoBin)
24+
.then(linkBinaryIntoBin)

0 commit comments

Comments
 (0)