in src/index.ts [14:82]
async function main(): Promise<void> {
const args = process.argv.slice(2);
let dirPath = process.cwd();
let onlyTestTsNext = false;
let expectOnly = false;
let shouldListen = false;
let lookingForTsLocal = false;
let tsLocal: string | undefined;
for (const arg of args) {
if (lookingForTsLocal) {
if (arg.startsWith("--")) {
throw new Error("Looking for local path for TS, but got " + arg);
}
tsLocal = resolve(arg);
lookingForTsLocal = false;
continue;
}
switch (arg) {
case "--installAll":
console.log("Cleaning old installs and installing for all TypeScript versions...");
console.log("Working...");
await cleanTypeScriptInstalls();
await installAllTypeScriptVersions();
return;
case "--localTs":
lookingForTsLocal = true;
break;
case "--version":
console.log(require("../package.json").version);
return;
case "--expectOnly":
expectOnly = true;
break;
case "--onlyTestTsNext":
onlyTestTsNext = true;
break;
// Only for use by types-publisher.
// Listens for { path, onlyTestTsNext } messages and ouputs { path, status }.
case "--listen":
shouldListen = true;
break;
default: {
if (arg.startsWith("--")) {
console.error(`Unknown option '${arg}'`);
usage();
process.exit(1);
}
const path = arg.indexOf("@") === 0 && arg.indexOf("/") !== -1
// we have a scoped module, e.g. @bla/foo
// which should be converted to bla__foo
? arg.substr(1).replace("/", "__")
: arg;
dirPath = joinPaths(dirPath, path);
}
}
}
if (lookingForTsLocal) {
throw new Error("Path for --localTs was not provided.");
}
if (shouldListen) {
listen(dirPath, tsLocal, onlyTestTsNext);
} else {
await installTypeScriptAsNeeded(tsLocal, onlyTestTsNext);
await runTests(dirPath, onlyTestTsNext, expectOnly, tsLocal);
}
}