Commit 625cdcd
authored
cpggenerator: only return
* cpggenerator: only return `Some(frontend)` if it's actually available
Before this, we'd return the frontend and happily invoke it.
Only to then fail with a slightly different exception and a long and
confusing stacktrace:
```
Caused by: java.lang.AssertionError: assertion failed: CPG generator does not exist at: path/to/js2cpg.sh
at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
at io.joern.console.cpgcreation.CpgGenerator.runShellCommand$$anonfun$1(CpgGenerator.scala:30)
at io.joern.console.cpgcreation.CpgGenerator.runShellCommand$$anonfun$adapted$1(CpgGenerator.scala:47)
at scala.util.Try$.apply(Try.scala:217)
at io.joern.console.cpgcreation.CpgGenerator.runShellCommand(CpgGenerator.scala:47)
at io.joern.console.cpgcreation.JsCpgGenerator.generate(JsCpgGenerator.scala:15)
at io.joern.console.cpgcreation.CpgGeneratorFactory.runGenerator(CpgGeneratorFactory.scala:59)
at io.joern.console.cpgcreation.ImportCode.$anonfun$5(ImportCode.scala:212)
at scala.Option.flatMap(Option.scala:283)
at io.joern.console.cpgcreation.ImportCode.io$joern$console$cpgcreation$ImportCode$$apply(ImportCode.scala:210)
at io.joern.console.cpgcreation.ImportCode.apply(ImportCode.scala:45)
```
This changes the above to a more meaningful and helpful:
```
io.joern.console.ConsoleException: No suitable CPG generator found for: /home/mp/testdata/shiftleft-js-demo/src/Controllers/Login.js
To get an overview of all available language modules, try `importCode`.
To choose a specific language, try `importCode.<language>`."
```
* fmt
* do this differently - some tests depend on how things were wired up previouslySome(frontend) if it's actually available (#5834)1 parent 97465ea commit 625cdcd
File tree
6 files changed
+43
-18
lines changed- console/src
- main/scala/io/joern/console/cpgcreation
- test/scala/io/joern/console
- testing
6 files changed
+43
-18
lines changedLines changed: 9 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
| 34 | + | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | | - | |
| 45 | + | |
47 | 46 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | | - | |
| 41 | + | |
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
44 | | - | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
100 | 102 | | |
101 | 103 | | |
102 | 104 | | |
103 | | - | |
| 105 | + | |
104 | 106 | | |
| 107 | + | |
105 | 108 | | |
106 | 109 | | |
107 | 110 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | 56 | | |
60 | 57 | | |
61 | 58 | | |
| |||
Lines changed: 23 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
80 | 94 | | |
81 | 95 | | |
82 | 96 | | |
| |||
107 | 121 | | |
108 | 122 | | |
109 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
110 | 131 | | |
111 | 132 | | |
112 | 133 | | |
| |||
118 | 139 | | |
119 | 140 | | |
120 | 141 | | |
| 142 | + | |
121 | 143 | | |
122 | 144 | | |
123 | 145 | | |
| |||
0 commit comments