Skip to content

Instantly share code, notes, and snippets.

@MinskLeo
Created September 17, 2023 16:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MinskLeo/749311c117996cf88e5594e61a4bb333 to your computer and use it in GitHub Desktop.
Save MinskLeo/749311c117996cf88e5594e61a4bb333 to your computer and use it in GitHub Desktop.
NX run-command interactive executor
Install version ^5.1.1 because version 6 is ESM only.
GitHub issue about it:
https://github.com/sindresorhus/execa/issues/489
yarn add -D execa@^5.1.1
{
"executors": {
"run-command": {
"implementation": "./run-command/impl",
"schema": "./run-command/schema.json",
"description": "Runs a command"
}
}
}
{
"type": "commonjs",
"executors": "./executor.json"
}
const execa = require('execa');
export default async function buildExecutor(options: { command: string; cwd?: string }) {
console.info(`🟡 Executing workspace:run-command...`);
await execa.command(options.command, {
cwd: options.cwd,
stdio: [process.stdin, process.stdout, 'pipe'],
});
console.info(`✅ Executing workspace:run-command finished!`);
return { success: true };
}
{
"$schema": "http://json-schema.org/schema",
"type": "object",
"cli": "nx",
"properties": {
"command": {
"type": "string",
"description": "The command to run"
},
"cwd": {
"type": "string",
"description": "The working directory to run the command in"
}
},
"required": ["command"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment