diff --git a/tools/executors/echo/executor.json b/tools/executors/echo/executor.json new file mode 100644 index 00000000..f18781c7 --- /dev/null +++ b/tools/executors/echo/executor.json @@ -0,0 +1,9 @@ +{ + "executors": { + "echo": { + "implementation": "./impl", + "schema": "./schema.json", + "description": "Runs `echo` (to test executors out)." + } + } +} diff --git a/tools/executors/echo/impl.ts b/tools/executors/echo/impl.ts new file mode 100644 index 00000000..d0361a67 --- /dev/null +++ b/tools/executors/echo/impl.ts @@ -0,0 +1,24 @@ +import type { ExecutorContext } from '@nrwl/devkit'; +import { exec } from 'child_process'; +import { promisify } from 'util'; + +export interface EchoExecutorOptions { + textToEcho: string; +} + +export default async function echoExecutor( + options: EchoExecutorOptions, + context: ExecutorContext +): Promise<{ success: boolean }> { + console.info(`Executing "echo"...`); + console.info(`Options: ${JSON.stringify(options, null, 2)}`); + + const { stdout, stderr } = await promisify(exec)( + `echo ${options.textToEcho}` + ); + console.log(stdout); + console.error(stderr); + + const success = !stderr; + return { success }; +} diff --git a/tools/executors/echo/package.json b/tools/executors/echo/package.json new file mode 100644 index 00000000..712554f0 --- /dev/null +++ b/tools/executors/echo/package.json @@ -0,0 +1,3 @@ +{ + "executors": "./executor.json" +} diff --git a/tools/executors/echo/schema.json b/tools/executors/echo/schema.json new file mode 100644 index 00000000..91bcfb9e --- /dev/null +++ b/tools/executors/echo/schema.json @@ -0,0 +1,11 @@ +{ + "$schema": "http://json-schema.org/schema", + "type": "object", + "cli": "nx", + "properties": { + "textToEcho": { + "type": "string", + "description": "Text To Echo" + } + } +}