diff options
| author | Akshay Nair <phenax5@gmail.com> | 2023-01-05 19:28:43 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2023-01-05 19:28:43 +0530 |
| commit | 395b01feaadb896c1747696cd874bd70de727110 (patch) | |
| tree | 120d73963432fdbbe63164da6b9253fe68a80809 /src/runtime.ts | |
| parent | a32741ec698473e9575679c145806fb96dc7ccf5 (diff) | |
| download | ts-types-lang-395b01feaadb896c1747696cd874bd70de727110.tar.gz ts-types-lang-395b01feaadb896c1747696cd874bd70de727110.zip | |
feat: adds getargs function
Diffstat (limited to 'src/runtime.ts')
| -rw-r--r-- | src/runtime.ts | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/runtime.ts b/src/runtime.ts index 8620add..b3c49c3 100644 --- a/src/runtime.ts +++ b/src/runtime.ts @@ -2,6 +2,7 @@ import { Project, ScriptTarget, Type, Node, StringLiteral, TypeFormatFlags, Synt import path from 'path' import { promises as fs } from 'fs' import readline from 'readline'; +import { stdout } from 'process'; const rl = readline.createInterface({ input: process.stdin, @@ -86,6 +87,12 @@ const accumulateResults = async (effTyp: Type, node: Node): Promise<string[]> => return [hash] }, + GetArgs: async () => { + const hash = createHash() + addResult(hash, `${JSON.stringify(process.argv.slice(2))}`) + return [hash] + }, + ReadLine: async () => { const line = await readLineFromStdin() const hash = createHash() @@ -118,6 +125,13 @@ const evalAccumulator = async (effNode: Node, node: Node) => { console.log(...effTyp.getTypeArguments().map(typeToString)); }, + PutString: async () => { + const [strinTyp] = effTyp.getTypeArguments() + const typString = typeToString(strinTyp) + const string = JSON.parse(!typString.startsWith('"') ? `"${typString}"` : typString) + stdout.write(string); + }, + Debug: async () => { const [labelTyp, valueTyp] = effTyp.getTypeArguments() const label = JSON.parse(typeToString(labelTyp)) |
