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

Commit fda065a

Browse files
Add notrackdep suffix to scope dependencies (#4)
* Add notrackdep suffix to scope dependencies * Apply suggestions from code review Co-Authored-By: Juan Antonio Fernández de Alba <[email protected]> * Applying suggested changes Co-authored-by: Juan Antonio Fernández de Alba <[email protected]>
1 parent 164c927 commit fda065a

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

dist/index.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11914,19 +11914,18 @@ const tc = __importStar(__webpack_require__(602));
1191411914
const version_parser_1 = __webpack_require__(368);
1191511915
const scopeAgentMetadataURL = "https://repo1.maven.org/maven2/com/undefinedlabs/scope/scope-agent/maven-metadata.xml";
1191611916
const scopeMavenInstrMetadataURL = "https://repo1.maven.org/maven2/com/undefinedlabs/scope/scope-instrumentation-for-maven/maven-metadata.xml";
11917+
const scopeNoTrackDep = "_scope_notrackdep";
1191711918
function instrument(allowBeta) {
1191811919
return __awaiter(this, void 0, void 0, function* () {
1191911920
const workdir = process.cwd();
1192011921
const [agentVersion, instrVersion] = yield Promise.all([version_parser_1.getVersionToUse(scopeAgentMetadataURL, allowBeta), version_parser_1.getVersionToUse(scopeMavenInstrMetadataURL, false)]);
1192111922
const scopeAgentPath = yield tc.downloadTool(`https://repo1.maven.org/maven2/com/undefinedlabs/scope/scope-agent/${agentVersion}/scope-agent-${agentVersion}.jar`);
11922-
if (!scopeAgentPath.endsWith(".jar")) {
11923-
yield io.mv(scopeAgentPath, scopeAgentPath + ".jar");
11924-
}
11923+
const finalScopeAgentPath = `${scopeAgentPath.replace('.jar', '')}${scopeNoTrackDep}.jar`;
11924+
yield io.mv(scopeAgentPath, finalScopeAgentPath);
1192511925
const mavenInstrumentatorPath = yield tc.downloadTool(`https://repo1.maven.org/maven2/com/undefinedlabs/scope/scope-instrumentation-for-maven/${instrVersion}/scope-instrumentation-for-maven-${instrVersion}.jar`);
11926-
if (!mavenInstrumentatorPath.endsWith(".jar")) {
11927-
yield io.mv(mavenInstrumentatorPath, mavenInstrumentatorPath + ".jar");
11928-
}
11929-
yield exec.exec("sh -c \"find " + workdir + " -name \\\"pom.xml\\\" -exec java -jar " + mavenInstrumentatorPath + ".jar \\\"" + scopeAgentPath + ".jar\\\" {} \\;\"");
11926+
const finalMavenInstrumentatorPath = `${mavenInstrumentatorPath.replace('.jar', '')}${scopeNoTrackDep}.jar`;
11927+
yield io.mv(mavenInstrumentatorPath, finalMavenInstrumentatorPath);
11928+
yield exec.exec(`sh -c "find ${workdir} -name \\"pom.xml\\" -exec java -jar ${finalMavenInstrumentatorPath} ${finalScopeAgentPath} {} \\;"`);
1193011929
});
1193111930
}
1193211931
exports.instrument = instrument;

src/executor.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@ import {getVersionToUse} from "./version-parser";
55

66
const scopeAgentMetadataURL = "https://repo1.maven.org/maven2/com/undefinedlabs/scope/scope-agent/maven-metadata.xml";
77
const scopeMavenInstrMetadataURL = "https://repo1.maven.org/maven2/com/undefinedlabs/scope/scope-instrumentation-for-maven/maven-metadata.xml";
8+
const scopeNoTrackDep = "_scope_notrackdep";
89

910
export async function instrument(allowBeta:boolean): Promise<void> {
1011
const workdir = process.cwd();
1112
const [agentVersion, instrVersion] = await Promise.all([getVersionToUse(scopeAgentMetadataURL, allowBeta), getVersionToUse(scopeMavenInstrMetadataURL, false)])
1213

1314
const scopeAgentPath = await tc.downloadTool(`https://repo1.maven.org/maven2/com/undefinedlabs/scope/scope-agent/${agentVersion}/scope-agent-${agentVersion}.jar`);
14-
if(!scopeAgentPath.endsWith(".jar")) {
15-
await io.mv(scopeAgentPath, scopeAgentPath+".jar");
16-
}
15+
const finalScopeAgentPath = `${scopeAgentPath.replace('.jar', '')}${scopeNoTrackDep}.jar`
16+
await io.mv(scopeAgentPath, finalScopeAgentPath);
1717

1818
const mavenInstrumentatorPath = await tc.downloadTool(`https://repo1.maven.org/maven2/com/undefinedlabs/scope/scope-instrumentation-for-maven/${instrVersion}/scope-instrumentation-for-maven-${instrVersion}.jar`);
19-
if(!mavenInstrumentatorPath.endsWith(".jar")){
20-
await io.mv(mavenInstrumentatorPath, mavenInstrumentatorPath+".jar");
21-
}
19+
const finalMavenInstrumentatorPath = `${mavenInstrumentatorPath.replace('.jar', '')}${scopeNoTrackDep}.jar`
20+
await io.mv(mavenInstrumentatorPath, finalMavenInstrumentatorPath);
2221

23-
await exec.exec("sh -c \"find "+workdir+" -name \\\"pom.xml\\\" -exec java -jar "+mavenInstrumentatorPath+".jar \\\""+scopeAgentPath+".jar\\\" {} \\;\"");
24-
}
22+
await exec.exec(`sh -c "find ${workdir} -name \\"pom.xml\\" -exec java -jar ${finalMavenInstrumentatorPath} ${finalScopeAgentPath} {} \\;"`);
23+
}

0 commit comments

Comments
 (0)