Files
medusa-store/packages/cli/medusa-dev-cli/src/local-npm-registry/cleanup-tasks.js
Harminder Virk 48e00169d2 breaking: move shared HTTP utils to the framework (#9402)
Fixes: FRMW-2728, FRMW-2729

After this PR gets merged the following middleware will be exported from the `@medusajs/framework/http` import path.

- applyParamsAsFilters
- clearFiltersByKey
- applyDefaultFilters
- setContext
- getQueryConfig
- httpCompression
- maybeApplyLinkFilter
- refetchEntities
- unlessPath
- validateBody
- validateQuery

Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
2024-10-03 09:42:00 +00:00

20 lines
421 B
JavaScript

const signalExit = require(`signal-exit`)
const cleanupTasks = new Set()
exports.registerCleanupTask = (taskFn) => {
cleanupTasks.add(taskFn)
return () => {
const result = taskFn()
cleanupTasks.delete(taskFn)
return result
}
}
signalExit(() => {
if (cleanupTasks.size) {
console.log(`Process exitted in middle of publishing - cleaning up`)
cleanupTasks.forEach((taskFn) => taskFn())
}
})