|
1 |
| -// const fs = require('fs') |
2 |
| -// const path = require('path') |
| 1 | +const fs = require('fs') |
| 2 | +const path = require('path') |
3 | 3 | const getBinary = require('./get-binary')
|
4 | 4 |
|
| 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 | + |
5 | 11 | // 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 | +} |
16 | 21 |
|
17 |
| -// Downloaded binary to /node_modules/binary-install/bin/{ name } |
| 22 | +// Downloaded binary to /bin/{ name } |
18 | 23 | getBinary().install()
|
19 |
| - // .then(linkBinaryIntoBin) |
| 24 | + .then(linkBinaryIntoBin) |
0 commit comments