summaryrefslogtreecommitdiff
path: root/extract-tsdefs/extract.ts
diff options
context:
space:
mode:
Diffstat (limited to 'extract-tsdefs/extract.ts')
-rw-r--r--extract-tsdefs/extract.ts23
1 files changed, 18 insertions, 5 deletions
diff --git a/extract-tsdefs/extract.ts b/extract-tsdefs/extract.ts
index b4721892..7793881a 100644
--- a/extract-tsdefs/extract.ts
+++ b/extract-tsdefs/extract.ts
@@ -19,11 +19,21 @@ import * as fs from "fs/promises";
import * as path from "path";
import * as prettier from "prettier";
-const currentDir = ".";
+if (process.argv.length != 4) {
+ console.log(
+ `usage: ${process.argv[0]} ${process.argv[1]} WALLET_CORE_REPO OUTFILE`
+ );
+ process.exit(2);
+}
+
+const walletRootDir = process.argv[2];
+const outfile = process.argv[3];
+
+const walletCoreDir = path.join(walletRootDir, "packages/taler-wallet-core");
const excludedNames = new Set(["TalerErrorCode", "WalletBackupContentV1"]);
const configFile = ts.findConfigFile(
- currentDir,
+ walletCoreDir,
ts.sys.fileExists,
"tsconfig.json"
);
@@ -33,7 +43,7 @@ const { config } = ts.readConfigFile(configFile, ts.sys.readFile);
const { options, fileNames, errors } = ts.parseJsonConfigFileContent(
config,
ts.sys,
- currentDir
+ walletCoreDir
);
const program = ts.createProgram({
@@ -44,7 +54,10 @@ const program = ts.createProgram({
const checker = program.getTypeChecker();
-const sourceFile = program.getSourceFile("src/wallet-api-types.ts");
+const walletApiTypesFiles = `${walletCoreDir}/src/wallet-api-types.ts`;
+console.log("api types file:", walletApiTypesFiles);
+
+const sourceFile = program.getSourceFile(walletApiTypesFiles);
if (!sourceFile) {
throw Error();
@@ -151,7 +164,7 @@ function gatherDecls(
}
const main = async () => {
- const f = await fs.open("out.md", "w");
+ const f = await fs.open(outfile, "w");
const gatherState: GatherState = {
declTexts: new Map<string, string>(),
};