MCPcopy
hub / github.com/evanw/esbuild / esbuildCommandAndArgs

Function esbuildCommandAndArgs

lib/npm/node.ts:51–79  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49let isInternalWorkerThread = worker_threads?.workerData?.esbuildVersion === ESBUILD_VERSION
50
51let esbuildCommandAndArgs = (): [string, string[]] => {
52 // Try to have a nice error message when people accidentally bundle esbuild
53 // without providing an explicit path to the binary, or when using WebAssembly.
54 if ((!ESBUILD_BINARY_PATH || WASM) && (path.basename(__filename) !== 'main.js' || path.basename(__dirname) !== 'lib')) {
55 throw new Error(
56 `The esbuild JavaScript API cannot be bundled. Please mark the "esbuild" ` +
57 `package as external so it's not included in the bundle.\n` +
58 `\n` +
59 `More information: The file containing the code for esbuild's JavaScript ` +
60 `API (${__filename}) does not appear to be inside the esbuild package on ` +
61 `the file system, which usually means that the esbuild package was bundled ` +
62 `into another file. This is problematic because the API needs to run a ` +
63 `binary executable inside the esbuild package which is located using a ` +
64 `relative path from the API code to the executable. If the esbuild package ` +
65 `is bundled, the relative path will be incorrect and the executable won't ` +
66 `be found.`)
67 }
68
69 if (WASM) {
70 return ['node', [path.join(__dirname, '..', 'bin', 'esbuild')]]
71 } else {
72 const { binPath, isWASM } = generateBinPath()
73 if (isWASM) {
74 return ['node', [binPath]]
75 } else {
76 return [binPath, []]
77 }
78 }
79}
80
81// Return true if stderr is a TTY
82let isTTY = () => tty.isatty(2)

Callers 2

ensureServiceIsRunningFunction · 0.85
runServiceSyncFunction · 0.85

Calls 2

generateBinPathFunction · 0.90
joinMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…