shlogg · Early preview
Ramu Narasinga @karthik-m22

Executing CLI Commands Programmatically With Execa And Child_process

Shadcn/ui uses execa, while CodeMirror uses child_process to execute CLI commands programmatically. Execa is optimized for programmatic usage and runs commands in scripts or libraries.

In this article, we analyse two ways to execute CLI commands programmatically found in Shadcn/ui and CodeMirror.
Have you ever wondered if it is possible to run CLI commands programmatically? We are going to look at how Shadcn/ui uses execa and how CodeMirror uses child_process to execute CLI programmaticaly.

  
  
  child_process usage in CodeMirror

CodeMirror is found to be using a Node.js API called child_process.execFileSync. Read more

function run(cmd, args, wd = root, { shell = false } = {}) {
  return child.execFileSync(cmd, args, {shell, cwd: wd, encoding: "utf8", stdio: ["ignore",...