Skip to content

Commit

Permalink
added mission in zip name flag
Browse files Browse the repository at this point in the history
  • Loading branch information
casianaoprut committed Feb 29, 2024
1 parent 5fc08bc commit a7f3422
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/context/MissionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export class MissionContext {

private _targets: string[] = []

private _missionNameInZipFile = false

runAll = true

private constructor() {
Expand Down Expand Up @@ -95,6 +97,14 @@ export class MissionContext {
this._targets = value
}

set missionNameInZipFile(value: boolean) {
this._missionNameInZipFile = value
}

get missionNameInZipFile(): boolean {
return this._missionNameInZipFile
}

public static getInstance(): MissionContext {
if (!MissionContext.instance) {
MissionContext.instance = new MissionContext()
Expand Down
1 change: 1 addition & 0 deletions src/parser/mission-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function parseMission(file: any): void {
missionContext.addVariable(REPO, targetPath)
missionContext.addVariable(REPO_NAME, path.basename(targetPath))
}
missionContext.missionNameInZipFile = file.missionNameInZipFile
parseIntoMap(file.environment).forEach((value, variableKey) =>
missionEnvVarProvider.addVariables({variableKey, value}))
parseMissionTargets(file.targets)
Expand Down
6 changes: 3 additions & 3 deletions src/runner/mission-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ export function unpackMission(missionFilePath?: string): void {
return
}
getUnpackTargets().forEach(targetPath => {
console.log(`Target path: ${targetPath}`)
const archiveName = path.basename(targetPath).split('.')[0]
console.log(`Unpacking ${archiveName}...`)
const zip = new AdmZip(targetPath)
const unpackedDirPath = path.resolve(`./${path.basename(targetPath)}-results`)
zip.extractAllTo(unpackedDirPath, true)
const initialMissionName = extractInitialMissionName(unpackedDirPath)
console.log(`Initial mission name: ${initialMissionName}`)
const initialMissionName = missionContext.missionNameInZipFile ? archiveName : extractInitialMissionName(unpackedDirPath)
missionContext.instruments.filter(instrument => instrument.actions.has(unpackActionKey))
.forEach(instrument => runUnpackAction(<DefaultAction>instrument.actions.get(unpackActionKey), instrument.name, unpackedDirPath, initialMissionName))
fs.remove(unpackedDirPath).then().catch((error) => console.error(`Error deleting folder ${unpackedDirPath}:`, error))
Expand Down

0 comments on commit a7f3422

Please sign in to comment.