Skip to content

Commit

Permalink
Fixed bug to run depminer extract from dxw and with \ and / on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioRivis committed Sep 22, 2022
1 parent 238d6de commit 348ba43
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
11 changes: 7 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ const {depminer} = require("./lib");
const {Command} = require("commander");

exports.depminerCommand = new Command()
.name('depminer')
.description('Run the Depminer tool')
.allowUnknownOption()
.action(depminer)
.name('depminer')
.description('Run the Depminer tool')
.option('-wd --working-directory', 'Selects the directory where Depminer will be run from.' +
` Defaults to the location where Depminer is installed: ${__dirname}. If set to true it will use the current working directory process.cwd()`,
false)
.allowUnknownOption()
.action(depminer)
4 changes: 2 additions & 2 deletions lib/lib.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const {JavaCaller} = require('java-caller');

async function depminer() {
async function depminer(options) {
const java = new JavaCaller({
jar: 'depminer.jar', // CLASSPATH referencing the package embedded jar files
mainClass: 'org.dxworks.depminer.DepMiKt',// Main class to call, must be available from CLASSPATH,
Expand All @@ -14,7 +14,7 @@ async function depminer() {
if(index === -1)
index = 1
args.splice(0, index + 1);
const {status} = await java.run(args);
const {status} = await java.run(args, {cwd: options?.workingDirectory? process.cwd(): __dirname});
process.exitCode = status;
}

Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<version>0.1.0-SNAPSHOT</version>

<properties>
<kotlin.version>1.4.31</kotlin.version>
<kotlin.version>1.7.10</kotlin.version>
<final.jar.name>depminer</final.jar.name>
<main.class>org.dxworks.depminer.DepMiKt</main.class>
</properties>
Expand All @@ -29,12 +29,12 @@
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>2.11.2</version>
<version>2.13.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
<version>2.12.2</version>
<version>2.13.4</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/dxworks/depminer/DepMi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.fasterxml.jackson.module.kotlin.KotlinModule
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import org.apache.commons.io.FileUtils
import org.apache.commons.io.IOCase
import org.apache.commons.io.filefilter.NotFileFilter
import org.apache.commons.io.filefilter.WildcardFileFilter
import org.dxworks.argumenthor.Argumenthor
Expand Down Expand Up @@ -103,7 +104,7 @@ private fun extract(

val packageFiles =
FileUtils.listFiles(
target.toFile(), WildcardFileFilter(fileNames).and(
target.toFile(), WildcardFileFilter(fileNames, IOCase.INSENSITIVE).and(
NotFileFilter(
WildcardFileFilter(
blacklistedGlobs.files.orEmpty()
Expand All @@ -122,12 +123,12 @@ private fun extract(
val newName =
"${file.nameWithoutExtension}-$index${file.extension.let { if (it.isNotEmpty()) ".$it" else "" }}"
file.copyTo(depminerResultsPath.resolve(newName).toFile())
resultsMap[newName] = file.relativeTo(target.toFile()).toString()
resultsMap[newName] = file.relativeTo(target.toFile()).normalize().toString()
}
} else {
entry.value.firstOrNull()?.also {
it.copyTo(depminerResultsPath.resolve(it.name).toFile())
resultsMap[it.name] = it.relativeTo(target.toFile()).toString()
resultsMap[it.name] = it.relativeTo(target.toFile()).normalize().toString()
}
}
}
Expand Down

0 comments on commit 348ba43

Please sign in to comment.