Skip to content

Commit

Permalink
Lab #18
Browse files Browse the repository at this point in the history
  • Loading branch information
christianliebel committed Oct 7, 2024
1 parent 093ccdf commit 3cebc2e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tools/my-plugin/src/executors/echo/executor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { PromiseExecutor, runExecutor as run } from '@nx/devkit';
import { joinPathFragments, PromiseExecutor, runExecutor as run } from '@nx/devkit';
import { EchoExecutorSchema } from './schema';
import { promisify } from 'util';
import { exec } from 'child_process';
import { writeFile } from 'fs/promises';

const runExecutor: PromiseExecutor<EchoExecutorSchema> = async (options, context) => {
console.log(options.value);
Expand All @@ -14,6 +17,12 @@ const runExecutor: PromiseExecutor<EchoExecutorSchema> = async (options, context
if (!res.success) return res;
}

const execPromise = promisify(exec);
const execResult = await execPromise('git rev-parse HEAD');

const path = joinPathFragments(context.root, 'dist', 'apps', context.projectName, 'browser', 'hash.txt');
await writeFile(path, execResult.stdout);

return {
success: true,
};
Expand Down

0 comments on commit 3cebc2e

Please sign in to comment.