|
1
|
import { join } from "path" |
|
2
|
import { fork } from "child_process" |
|
3
|
import isTruthy from "./is-truthy" |
|
4
|
|
|
5
|
const MEDUSA_TELEMETRY_VERBOSE = process.env.MEDUSA_TELEMETRY_VERBOSE || false |
|
6
|
|
|
7
|
function createFlush(enabled) { |
|
8
|
if (!enabled) { |
|
9
|
return |
|
10
|
} |
|
11
|
|
|
12
|
return async function flush() { |
|
13
|
if (isTruthy(MEDUSA_TELEMETRY_VERBOSE)) { |
|
14
|
console.log("Flushing queue...") |
|
15
|
} |
|
16
|
|
|
17
|
const forked = fork(join(__dirname, `send.js`), { |
|
18
|
detached: true, |
|
19
|
stdio: MEDUSA_TELEMETRY_VERBOSE ? `inherit` : `ignore`, |
|
20
|
execArgv: [], |
|
21
|
}) |
|
22
|
forked.unref() |
|
23
|
} |
|
24
|
} |
|
25
|
|
|
26
|
export default createFlush |