fix: enable added week deletion and preserve learning concepts when cloning courses
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { AsyncLocalStorage } from 'node:async_hooks'
|
||||
|
||||
export const moduleProgress = new AsyncLocalStorage<(message: string) => void>()
|
||||
|
||||
export function reportModuleProgress(message: string): void {
|
||||
moduleProgress.getStore()?.(message)
|
||||
}
|
||||
|
||||
export function createModuleProgressParser(): (chunk: string) => void {
|
||||
const report = moduleProgress.getStore()
|
||||
let pending = ''
|
||||
return (chunk) => {
|
||||
if (!report) return
|
||||
pending += chunk
|
||||
const lines = pending.split('\n')
|
||||
pending = lines.pop()!.slice(-4096)
|
||||
for (const line of lines) {
|
||||
if (line.startsWith('LMS_MODULE_PROGRESS:')) report(line.slice('LMS_MODULE_PROGRESS:'.length).trim())
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user