Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: follow Node.js flag handling (#133)
- Loading branch information
1 parent
5d8cc04
commit 76a83c2
Showing
6 changed files
with
85 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { | ||
typeFlag, | ||
type Flags, | ||
type TypeFlagOptions, | ||
} from 'type-flag'; | ||
|
||
export const ignoreAfterArgument = (): TypeFlagOptions['ignore'] => { | ||
let ignore = false; | ||
|
||
return (type) => { | ||
if (ignore) { | ||
return true; | ||
} | ||
const isArgument = type === 'argument'; | ||
if (isArgument || type === 'unknown-flag') { | ||
ignore = isArgument; | ||
return true; | ||
} | ||
}; | ||
}; | ||
|
||
export function removeArgvFlags( | ||
tsxFlags: Flags, | ||
argv = process.argv.slice(2), | ||
) { | ||
typeFlag( | ||
tsxFlags, | ||
argv, | ||
{ | ||
ignore: ignoreAfterArgument(), | ||
}, | ||
); | ||
|
||
return argv; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters