aboutsummaryrefslogtreecommitdiff
path: root/packages/pogen/po2.js
blob: 532a1522f36ed8d0cbad36a88d91ac32ca1589a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const ts = require("typescript");

const configPath = ts.findConfigFile(
    /*searchPath*/ "./",
    ts.sys.fileExists,
    "tsconfig.json"
  );
if (!configPath) {
  throw new Error("Could not find a valid 'tsconfig.json'.");
}

console.log(configPath);

const cmdline = ts.getParsedCommandLineOfConfigFile(configPath, {}, {
  fileExists: ts.sys.fileExists,
  getCurrentDirectory: ts.sys.getCurrentDirectory,
  onUnRecoverableConfigFileDiagnostic: (e) => console.log(e),
  readDirectory: ts.sys.readDirectory,
  readFile: ts.sys.readFile,
  useCaseSensitiveFileNames: true,
})

console.log(cmdline);

const prog = ts.createProgram({
  options: cmdline.options,
  rootNames: cmdline.fileNames,
});

const allFiles = prog.getSourceFiles();

console.log(allFiles.map(x => x.path));