const path = require('path')

const postInstallScriptPath = path.join(__dirname, '..', 'dist', 'scripts', 'postinstall.js')
const localInstallScriptPath = path.join(__dirname, '..', 'dist', 'scripts', 'localinstall.js')

try {
  // that's when we develop in the monorepo, `dist` does not exist yet
  // so we compile postinstall script and trigger it immediately after
  if (require('../package.json').version === '0.0.0') {
    const execa = require('execa')
    const buildScriptPath = path.join(__dirname, '..', 'helpers', 'build.ts')

    execa.sync('node', ['-r', 'esbuild-register', buildScriptPath], {
      env: { DEV: true },
    })

    require(localInstallScriptPath) // may install engines overrides
  }
} catch {}

// that's the normal path, when users get this package ready/installed
require(postInstallScriptPath)

@@ -636,80 +636,188 @@
     
-%7D)%0A%0A    require(localInstallScriptPath) // may install engines overrides
+  stdio: 'inherit',%0A    %7D)%0A%0A    // if enabled, it will install engine overrides into the cache dir%0A    execa.sync('node', %5BlocalInstallScriptPath%5D, %7B%0A      stdio: 'inherit',%0A    %7D)
 %0A  %7D

fix the local engine install (#15326)