mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-03 06:09:02 +02:00
Merge pull request #24466 from overleaf/ls-script-runner
Script runner GitOrigin-RevId: 4cc7004f05177dba2a2151aa6db7e75fb679d11d
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
// Import the script runner utility (adjust the path as needed)
|
||||
import { scriptRunner } from '../lib/ScriptRunner.mjs'
|
||||
|
||||
const subJobs = 30
|
||||
|
||||
/**
|
||||
* Your script's main work goes here.
|
||||
* It must be an async function and accept `trackProgress`.
|
||||
* @param {(message: string) => Promise<void>} trackProgress - Call this to log progress.
|
||||
*/
|
||||
async function main(trackProgress) {
|
||||
for (let i = 0; i < subJobs; i++) {
|
||||
await new Promise(resolve => setTimeout(() => resolve(), 1000))
|
||||
await trackProgress(`Job in progress ${i + 1}/${subJobs}`)
|
||||
}
|
||||
await trackProgress('Job finished')
|
||||
}
|
||||
|
||||
// Define any variables your script needs (optional)
|
||||
const scriptVariables = {
|
||||
subJobs,
|
||||
}
|
||||
|
||||
// --- Execute the script using the runner with async/await ---
|
||||
try {
|
||||
await scriptRunner(main, scriptVariables)
|
||||
process.exit()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
process.exit(1)
|
||||
}
|
||||
Reference in New Issue
Block a user