Skip to content

Commit 39a60b9

Browse files
authored
On --overwrite, first remove project before recreating it (#1070)
1 parent 630e1c5 commit 39a60b9

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

console/src/main/scala/io/shiftleft/console/BridgeBase.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,17 +191,20 @@ trait BridgeBase {
191191
}
192192

193193
val bundleName = config.bundleToRun.get
194-
val src = config.src.get
194+
val src = better.files.File(config.src.get).path.toAbsolutePath.toString
195195
val language = config.language.getOrElse("c")
196196
val storeCode = if (config.store) { "save" } else { "" }
197197
val code = s"""
198198
| if (${config.overwrite} || !workspace.projectExists("$src")) {
199+
| workspace.projects
200+
| .filter(_.inputPath == "$src")
201+
| .map(_.name).foreach(n => workspace.removeProject(n))
199202
| importCode.$language("$src")
200203
| save
201204
| } else {
202205
| println("Using existing CPG - Use `--overwrite` if this is not what you want")
203206
| workspace.projects
204-
| .filter(x => x.inputPath == better.files.File("$src").path.toAbsolutePath.toString)
207+
| .filter(x => x.inputPath == "$src")
205208
| .map(_.name).map(open)
206209
| }
207210
| run.$bundleName

0 commit comments

Comments
 (0)