MCPcopy Index your code
hub / github.com/TypeStrong/ts-node / parseArgv

Function parseArgv

src/bin.ts:98–274  ·  view source on GitHub ↗
(argv: string[], entrypointArgs: Record<string, any>)

Source from the content-addressed store, hash-verified

96}
97
98function parseArgv(argv: string[], entrypointArgs: Record<string, any>) {
99 arg ??= require('arg');
100 // HACK: technically, this function is not marked @internal so it's possible
101 // that libraries in the wild are doing `require('ts-node/dist/bin').main({'--transpile-only': true})`
102 // We can mark this function @internal in next major release.
103 // For now, rewrite args to avoid a breaking change.
104 entrypointArgs = { ...entrypointArgs };
105 for (const key of Object.keys(entrypointArgs)) {
106 entrypointArgs[
107 key.replace(
108 /([a-z])-([a-z])/g,
109 (_$0, $1, $2: string) => `${$1}${$2.toUpperCase()}`
110 )
111 ] = entrypointArgs[key];
112 }
113
114 const args = {
115 ...entrypointArgs,
116 ...arg(
117 {
118 // Node.js-like options.
119 '--eval': String,
120 '--interactive': Boolean,
121 '--print': Boolean,
122 '--require': [String],
123
124 // CLI options.
125 '--help': Boolean,
126 '--cwdMode': Boolean,
127 '--scriptMode': Boolean,
128 '--version': arg.COUNT,
129 '--showConfig': Boolean,
130 '--esm': Boolean,
131
132 // Project options.
133 '--cwd': String,
134 '--files': Boolean,
135 '--compiler': String,
136 '--compilerOptions': parse,
137 '--project': String,
138 '--ignoreDiagnostics': [String],
139 '--ignore': [String],
140 '--transpileOnly': Boolean,
141 '--transpiler': String,
142 '--swc': Boolean,
143 '--typeCheck': Boolean,
144 '--compilerHost': Boolean,
145 '--pretty': Boolean,
146 '--skipProject': Boolean,
147 '--skipIgnore': Boolean,
148 '--preferTsExts': Boolean,
149 '--logError': Boolean,
150 '--emit': Boolean,
151 '--scope': Boolean,
152 '--scopeDir': String,
153 '--noExperimentalReplAwait': Boolean,
154 '--experimentalSpecifierResolution': String,
155

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…