aboutsummaryrefslogtreecommitdiff
path: root/src/context.ts
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2023-01-09 19:38:28 +0530
committerAkshay Nair <phenax5@gmail.com>2023-01-09 19:38:28 +0530
commit2af211f1bd6a5c81ee7acd2ded2bfacf4dcfb2a4 (patch)
treeb1face34438aab4a702ace78c027b280e967f388 /src/context.ts
parent592f866637bfb8ef8a4a5c31e0984abf6df82532 (diff)
downloadts-types-lang-2af211f1bd6a5c81ee7acd2ded2bfacf4dcfb2a4.tar.gz
ts-types-lang-2af211f1bd6a5c81ee7acd2ded2bfacf4dcfb2a4.zip
feat: cli donezy
Diffstat (limited to '')
-rw-r--r--src/context.ts14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/context.ts b/src/context.ts
index 7759215..e0c0fa5 100644
--- a/src/context.ts
+++ b/src/context.ts
@@ -5,7 +5,11 @@ import { Ctx } from './types'
const RESULT_TYPE_NAME = '__$result'
-export const createContext = (): Ctx => {
+export interface CtxOptions {
+ filePath: string
+}
+
+export const createContext = (options: CtxOptions): Ctx => {
const project = new Project({
compilerOptions: {
target: ScriptTarget.ES3,
@@ -14,13 +18,7 @@ export const createContext = (): Ctx => {
const typeChecker = project.getTypeChecker()
- const [filePath] = process.argv.slice(2)
-
- if (!filePath) {
- throw new Error('Must specify ts file to run')
- }
-
- const sourceFile = project.addSourceFileAtPath(path.resolve(filePath))
+ const sourceFile = project.addSourceFileAtPath(path.resolve(options.filePath))
const entryPoint = sourceFile.getExportedDeclarations().get('main')?.[0]