-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
117 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,37 @@ | ||
import { executeCliCommand } from '../helpers'; | ||
import { Job } from '../../../entities/job'; | ||
import { executeCliCommand, getRepoDir } from '../helpers'; | ||
|
||
interface PersistenceModuleParams { | ||
bundlePath: string; | ||
jobId?: string; | ||
repoOwner?: string; | ||
job: Job; | ||
preppedLogger: (message: string) => void; | ||
} | ||
export async function persistenceModule({ | ||
bundlePath, | ||
jobId, | ||
repoOwner = 'docs-builder-bot', | ||
}: PersistenceModuleParams) { | ||
export async function persistenceModule({ job, preppedLogger }: PersistenceModuleParams) { | ||
const githubUser = job.payload.repoOwner; | ||
const repoDir = getRepoDir(job.payload.repoName, job.payload.directory); | ||
const bundlePath = `${repoDir}/bundle.zip`; | ||
|
||
const args = [ | ||
`${process.cwd()}/modules/persistence/dist/index.js`, | ||
'--unhandled-rejections=strict', | ||
'--path', | ||
bundlePath, | ||
'--githubUser', | ||
repoOwner, | ||
githubUser, | ||
]; | ||
|
||
if (jobId) { | ||
if (job._id) { | ||
args.push('--jobId'); | ||
args.push(jobId); | ||
args.push(job._id); | ||
} | ||
|
||
preppedLogger(`persistence args: ${args}`); | ||
|
||
const { outputText } = await executeCliCommand({ | ||
command: 'node', | ||
args, | ||
}); | ||
|
||
preppedLogger(`output text persistence: ${outputText}`); | ||
|
||
return outputText; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters