Skip to content
This repository has been archived by the owner on Aug 14, 2020. It is now read-only.

Commit

Permalink
Use jar library directly
Browse files Browse the repository at this point in the history
  • Loading branch information
drodriguezhdez committed Nov 29, 2019
1 parent a2b48a3 commit e035f37
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
14 changes: 11 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4041,14 +4041,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
const exec = __importStar(__webpack_require__(230));
const io = __importStar(__webpack_require__(954));
const tc = __importStar(__webpack_require__(602));
const IS_WINDOWS = process.platform === 'win32';
function instrument(agentVersion) {
return __awaiter(this, void 0, void 0, function* () {
const workdir = process.cwd();
const scopeAgentPath = yield tc.downloadTool("https://repo1.maven.org/maven2/com/undefinedlabs/scope/scope-agent/" + agentVersion + "/scope-agent-" + agentVersion + ".jar");
let scopeAgentPath = yield tc.downloadTool("https://repo1.maven.org/maven2/com/undefinedlabs/scope/scope-agent/" + agentVersion + "/scope-agent-" + agentVersion + ".jar");
if (!scopeAgentPath.endsWith(".jar")) {
yield io.mv(scopeAgentPath, scopeAgentPath + ".jar");
}
yield exec.exec("sh -c \"docker run -v " + workdir + ":/home/project -e \\\"SCOPE_AGENT_PATH=" + scopeAgentPath + ".jar\\\" codescope/scope-instrumentation-for-maven\"");
let mavenInstrumentatorPath = yield tc.downloadTool("https://repo1.maven.org/maven2/com/undefinedlabs/scope/scope-instrumentation-for-maven/0.1.0/scope-instrumentation-for-maven-0.1.0.jar");
if (!mavenInstrumentatorPath.endsWith(".jar")) {
yield io.mv(mavenInstrumentatorPath, mavenInstrumentatorPath + ".jar");
}
if (IS_WINDOWS) {
scopeAgentPath = scopeAgentPath.replace("\\", "\\\\");
mavenInstrumentatorPath = mavenInstrumentatorPath.replace("\\", "\\\\");
}
yield exec.exec("sh -c \"find . -name \\\"pom.xml\\\" -exec java -jar " + mavenInstrumentatorPath + ".jar \\\"" + scopeAgentPath + ".jar\\\" {} \\;\"");
});
}
exports.instrument = instrument;
Expand Down
8 changes: 6 additions & 2 deletions src/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ import * as tc from '@actions/tool-cache';
export async function instrument(agentVersion:string): Promise<void> {
const workdir = process.cwd();
const scopeAgentPath = await tc.downloadTool("https://repo1.maven.org/maven2/com/undefinedlabs/scope/scope-agent/"+agentVersion+"/scope-agent-"+agentVersion+".jar");

if(!scopeAgentPath.endsWith(".jar")) {
await io.mv(scopeAgentPath, scopeAgentPath+".jar");
}

await exec.exec("sh -c \"docker run -v "+workdir+":/home/project -e \\\"SCOPE_AGENT_PATH="+scopeAgentPath+".jar\\\" codescope/scope-instrumentation-for-maven\"");
const mavenInstrumentatorPath = await tc.downloadTool("https://repo1.maven.org/maven2/com/undefinedlabs/scope/scope-instrumentation-for-maven/0.1.0/scope-instrumentation-for-maven-0.1.0.jar");
if(!mavenInstrumentatorPath.endsWith(".jar")){
await io.mv(mavenInstrumentatorPath, mavenInstrumentatorPath+".jar");
}

await exec.exec("sh -c \"find "+workdir+" -name \\\"pom.xml\\\" -exec java -jar "+mavenInstrumentatorPath+".jar \\\""+scopeAgentPath+".jar\\\" {} \\;\"");
}

0 comments on commit e035f37

Please sign in to comment.