MCPcopy
hub / github.com/tailwindlabs/tailwindcss / exec

Function exec

integrations/utils.ts:123–204  ·  view source on GitHub ↗
(
          command: string,
          childProcessOptions: ChildProcessOptions = {},
          execOptions: ExecOptions = {},
        )

Source from the content-addressed store, hash-verified

121 expect: options.expect,
122 parseSourceMap,
123 async exec(
124 command: string,
125 childProcessOptions: ChildProcessOptions = {},
126 execOptions: ExecOptions = {},
127 ) {
128 let cwd = childProcessOptions.cwd ?? root
129 let originalCommand = command
130
131 // Avoid `pnpm exec upgrade` on Windows because the upgrader runs
132 // `pnpm add`, which rewrites Windows `.cmd` shims while the current
133 // shim is still executing.
134 //
135 // Pretty sure this is a pnpm v11 bug on Windows.
136 if (IS_WINDOWS && command.includes('pnpm exec upgrade')) {
137 for (let base = cwd; ; base = path.dirname(base)) {
138 let upgradeBin = path.join(
139 base,
140 'node_modules',
141 '@tailwindcss',
142 'upgrade',
143 'dist',
144 'index.mjs',
145 )
146
147 try {
148 await fs.access(upgradeBin)
149 command = command.replace('pnpm exec upgrade', `node "${upgradeBin}"`)
150 break
151 } catch (error: any) {
152 if (error?.code !== 'ENOENT') throw error
153 }
154
155 let parent = path.dirname(base)
156 if (parent === base) {
157 throw new Error(`Unable to resolve @tailwindcss/upgrade from ${cwd}`)
158 }
159 }
160 }
161
162 if (debug && cwd !== root) {
163 let relative = path.relative(root, cwd)
164 if (relative[0] !== '.') relative = `./${relative}`
165 console.log(`> cd ${relative}`)
166 }
167 if (debug) console.log(`> ${command}`)
168 return new Promise((resolve, reject) => {
169 let child = exec(
170 command,
171 {
172 cwd,
173 ...childProcessOptions,
174 env: {
175 ...process.env,
176 ...childProcessOptions.env,
177 },
178 },
179 (error, stdout, stderr) => {
180 if (error) {

Callers 15

addFunction · 0.85
removeFunction · 0.85
packFunction · 0.85
index.test.tsFile · 0.85
next.test.tsFile · 0.85
multi-root.test.tsFile · 0.85
source.test.tsFile · 0.85
config.test.tsFile · 0.85

Calls 3

errorMethod · 0.80
resolveFunction · 0.50
endMethod · 0.45

Tested by

no test coverage detected