-
Notifications
You must be signed in to change notification settings - Fork 66
/
whichbin.js
executable file
·47 lines (38 loc) · 1.29 KB
/
whichbin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env node
/* eslint-disable n/shebang */
// @ts-check
const path = require('node:path')
const { getOptionsForBin } = require('./index.js')
const { FEATURE } = require('./toggles.js')
start().catch((err) => {
console.error(err)
process.exit(1)
})
async function start() {
FEATURE.bins = true
const binName = path.basename(process.argv[1])
const rootDir = process.env.INIT_CWD || process.cwd()
const currentBinCandidates = await getOptionsForBin({
rootDir,
name: binName,
})
if (!currentBinCandidates) {
return console.error(
`There's no candidates to run as the '${binName}' bin script`
)
}
console.error(`-lavamoat--allow-scripts---------------------------------------------------
There's no policy for the '${binName}' bin script.
You can allow this script to run by adding it to lavamoat->allowBins in package.json
Add a line like this in allowBins:
"${binName}": "${currentBinCandidates[0].fullLinkPath}"
`)
if (currentBinCandidates.length > 1) {
console.error(`Choose one of the following paths for the value:
${currentBinCandidates.map((c) => c.fullLinkPath).join('\n')}
`)
}
console.error(`After you're done configuring, run allow-scripts again.
---------------------------------------------------------------------------`)
process.exit(42)
}