Skip to content

Commit

Permalink
fix(allow-scripts): update some types
Browse files Browse the repository at this point in the history
  • Loading branch information
boneskull committed Oct 5, 2023
1 parent de2fcc9 commit 24a306f
Show file tree
Hide file tree
Showing 3 changed files with 205 additions and 113 deletions.
17 changes: 11 additions & 6 deletions packages/allow-scripts/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

const yargs = require('yargs/yargs')
const { hideBin } = require('yargs/helpers')
const { runAllowedPackages, setDefaultConfiguration, printPackagesList } = require('./index.js')
const {
runAllowedPackages,
setDefaultConfiguration,
printPackagesList,
} = require('./index.js')
const { writeRcFile, editPackageJson } = require('./setup.js')
const { FEATURE } = require('./toggles')

Expand All @@ -11,11 +15,11 @@ start().catch((err) => {
process.exit(1)
})

async function start () {
async function start() {
const rootDir = process.cwd()

const parsedArgs = parseArgs()
const command = parsedArgs.command || 'run'
const command = String(parsedArgs.command || 'run')
FEATURE.bins = parsedArgs.experimentalBins

switch (command) {
Expand All @@ -41,12 +45,12 @@ async function start () {
}
// (error) unrecognized
default: {
throw new Error(`@lavamoat/allow-scripts - unknown command "${parsedArgs.command}"`)
throw new Error(`@lavamoat/allow-scripts - unknown command "${command}"`)
}
}
}

function parseArgs () {
function parseArgs() {
const argsParser = yargs(hideBin(process.argv))
.usage('Usage: $0 <command> [options]')
.command('$0', 'run the allowed scripts')
Expand All @@ -55,7 +59,8 @@ function parseArgs () {
.command('setup', 'configure local repository to use allow-scripts')
.option('experimental-bins', {
alias: 'bin',
describe: 'opt-in to set up experimental protection against bin script confusion',
describe:
'opt-in to set up experimental protection against bin script confusion',
type: 'boolean',
default: false,
})
Expand Down
Loading

0 comments on commit 24a306f

Please sign in to comment.