in packages/apps/autorest/src/autorest-as-a-service.ts [82:144]
export async function resolveEntrypoint(localPath: string, entrypoint: string): Promise<string | undefined> {
try {
// did they specify the package directory directly
if (await isDirectory(localPath)) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const pkg = nodeRequire(`${localPath}/package.json`);
if (pkg.name === "autorest") {
// you've tried loading the bootstrapper not the core!
console.error(`The location you have specified is not autorest-core, it's autorest bootstrapper: ${pkg.name}`);
process.exit(1);
}
if (args.debug) {
console.log(`Examining AutoRest core package: ${pkg.name}`);
}
if (pkg.name === oldCorePackage || pkg.name === newCorePackage) {
if (args.debug) {
console.log("Looks like a core package.");
}
switch (entrypoint) {
case "main":
case "main.js":
entrypoint = pkg.main;
break;
case "language-service":
case "language-service.js":
case "autorest-language-service":
entrypoint = pkg.bin["autorest-language-service"];
break;
case "autorest":
case "autorest-core":
case "app.js":
case "app":
entrypoint = pkg.bin["autorest-core"] || pkg.bin["core"];
break;
case "module":
// special case: look for the main entrypoint
// but return the module folder
if (await isFile(`${localPath}/${pkg.main}`)) {
if (args.debug) {
console.log(`special case: '${localPath}/${pkg.main}' .`);
}
return localPath.replace(/\\/g, "/");
}
}
const path = `${localPath}/${entrypoint}`;
if (await isFile(path)) {
if (args.debug) {
console.log(`Using Entrypoint: '${localPath}/${entrypoint}' .`);
}
return path.replace(/\\/g, "/");
}
}
}
} catch {
// no worries
}
return undefined;
}