import { NexeCompiler } from '../compiler' import { semverGt } from '../util' export default async function disableNodeCli(compiler: NexeCompiler, next: () => Promise) { if (compiler.options.enableNodeCli) { return next() } if (semverGt(compiler.target.version, '11.6.0')) { await compiler.replaceInFileAsync( 'src/node.cc', /(? 1/g, (match) => { if (matches++) { return 'false' } return match }) } else { const nodeccMarker = 'argv[index][0] ==' await compiler.replaceInFileAsync( 'src/node.cc', `${nodeccMarker} '-'`, // allow NODE_OPTIONS, introduced in 8.0 semverGt(compiler.target.version, '7.99') ? `(${nodeccMarker} (is_env ? '-' : ']'))` : `(${nodeccMarker} ']')` ) } return next() }