From fda065afea7276cef6ee0c7e91a10e67163ab6db Mon Sep 17 00:00:00 2001 From: Daniel Rodriguez Hernandez Date: Tue, 28 Apr 2020 12:45:17 +0200 Subject: [PATCH] Add notrackdep suffix to scope dependencies (#4) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add notrackdep suffix to scope dependencies * Apply suggestions from code review Co-Authored-By: Juan Antonio Fernández de Alba * Applying suggested changes Co-authored-by: Juan Antonio Fernández de Alba --- dist/index.js | 13 ++++++------- src/executor.ts | 15 +++++++-------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/dist/index.js b/dist/index.js index b0ad246..0004095 100644 --- a/dist/index.js +++ b/dist/index.js @@ -11914,19 +11914,18 @@ const tc = __importStar(__webpack_require__(602)); const version_parser_1 = __webpack_require__(368); const scopeAgentMetadataURL = "https://repo1.maven.org/maven2/com/undefinedlabs/scope/scope-agent/maven-metadata.xml"; const scopeMavenInstrMetadataURL = "https://repo1.maven.org/maven2/com/undefinedlabs/scope/scope-instrumentation-for-maven/maven-metadata.xml"; +const scopeNoTrackDep = "_scope_notrackdep"; function instrument(allowBeta) { return __awaiter(this, void 0, void 0, function* () { const workdir = process.cwd(); const [agentVersion, instrVersion] = yield Promise.all([version_parser_1.getVersionToUse(scopeAgentMetadataURL, allowBeta), version_parser_1.getVersionToUse(scopeMavenInstrMetadataURL, false)]); const 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"); - } + const finalScopeAgentPath = `${scopeAgentPath.replace('.jar', '')}${scopeNoTrackDep}.jar`; + yield io.mv(scopeAgentPath, finalScopeAgentPath); const mavenInstrumentatorPath = yield tc.downloadTool(`https://repo1.maven.org/maven2/com/undefinedlabs/scope/scope-instrumentation-for-maven/${instrVersion}/scope-instrumentation-for-maven-${instrVersion}.jar`); - if (!mavenInstrumentatorPath.endsWith(".jar")) { - yield io.mv(mavenInstrumentatorPath, mavenInstrumentatorPath + ".jar"); - } - yield exec.exec("sh -c \"find " + workdir + " -name \\\"pom.xml\\\" -exec java -jar " + mavenInstrumentatorPath + ".jar \\\"" + scopeAgentPath + ".jar\\\" {} \\;\""); + const finalMavenInstrumentatorPath = `${mavenInstrumentatorPath.replace('.jar', '')}${scopeNoTrackDep}.jar`; + yield io.mv(mavenInstrumentatorPath, finalMavenInstrumentatorPath); + yield exec.exec(`sh -c "find ${workdir} -name \\"pom.xml\\" -exec java -jar ${finalMavenInstrumentatorPath} ${finalScopeAgentPath} {} \\;"`); }); } exports.instrument = instrument; diff --git a/src/executor.ts b/src/executor.ts index f322dff..29a2fb6 100644 --- a/src/executor.ts +++ b/src/executor.ts @@ -5,20 +5,19 @@ import {getVersionToUse} from "./version-parser"; const scopeAgentMetadataURL = "https://repo1.maven.org/maven2/com/undefinedlabs/scope/scope-agent/maven-metadata.xml"; const scopeMavenInstrMetadataURL = "https://repo1.maven.org/maven2/com/undefinedlabs/scope/scope-instrumentation-for-maven/maven-metadata.xml"; +const scopeNoTrackDep = "_scope_notrackdep"; export async function instrument(allowBeta:boolean): Promise { const workdir = process.cwd(); const [agentVersion, instrVersion] = await Promise.all([getVersionToUse(scopeAgentMetadataURL, allowBeta), getVersionToUse(scopeMavenInstrMetadataURL, false)]) 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"); - } + const finalScopeAgentPath = `${scopeAgentPath.replace('.jar', '')}${scopeNoTrackDep}.jar` + await io.mv(scopeAgentPath, finalScopeAgentPath); const mavenInstrumentatorPath = await tc.downloadTool(`https://repo1.maven.org/maven2/com/undefinedlabs/scope/scope-instrumentation-for-maven/${instrVersion}/scope-instrumentation-for-maven-${instrVersion}.jar`); - if(!mavenInstrumentatorPath.endsWith(".jar")){ - await io.mv(mavenInstrumentatorPath, mavenInstrumentatorPath+".jar"); - } + const finalMavenInstrumentatorPath = `${mavenInstrumentatorPath.replace('.jar', '')}${scopeNoTrackDep}.jar` + await io.mv(mavenInstrumentatorPath, finalMavenInstrumentatorPath); - await exec.exec("sh -c \"find "+workdir+" -name \\\"pom.xml\\\" -exec java -jar "+mavenInstrumentatorPath+".jar \\\""+scopeAgentPath+".jar\\\" {} \\;\""); -} \ No newline at end of file + await exec.exec(`sh -c "find ${workdir} -name \\"pom.xml\\" -exec java -jar ${finalMavenInstrumentatorPath} ${finalScopeAgentPath} {} \\;"`); +}