Created
September 17, 2023 16:30
-
-
Save MinskLeo/749311c117996cf88e5594e61a4bb333 to your computer and use it in GitHub Desktop.
NX run-command interactive executor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"executors": { | |
"run-command": { | |
"implementation": "./run-command/impl", | |
"schema": "./run-command/schema.json", | |
"description": "Runs a command" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type": "commonjs", | |
"executors": "./executor.json" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$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