Skip to content

Commit

Permalink
Lab #19
Browse files Browse the repository at this point in the history
  • Loading branch information
christianliebel committed Oct 7, 2024
1 parent 3cebc2e commit 751fdad
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
7 changes: 6 additions & 1 deletion apps/my-workspace/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
"targets": {
"echo": {
"executor": "@my-workspace/my-plugin:echo",
"options": {}
"options": { "value": "Hello from options" },
"configurations": {
"dev": { "value": "Hello from dev" },
"ci": { "createGitHash": true }
},
"defaultConfiguration": "dev"
},
"build": {
"executor": "@angular-devkit/build-angular:application",
Expand Down
10 changes: 6 additions & 4 deletions tools/my-plugin/src/executors/echo/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ const runExecutor: PromiseExecutor<EchoExecutorSchema> = async (options, context
if (!res.success) return res;
}

const execPromise = promisify(exec);
const execResult = await execPromise('git rev-parse HEAD');
if (options.createGitHash) {
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);
const path = joinPathFragments(context.root, 'dist', 'apps', context.projectName, 'browser', 'hash.txt');
await writeFile(path, execResult.stdout);
}

return {
success: true,
Expand Down
1 change: 1 addition & 0 deletions tools/my-plugin/src/executors/echo/schema.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export interface EchoExecutorSchema {
value: string;
createGitHash: boolean;
}
5 changes: 5 additions & 0 deletions tools/my-plugin/src/executors/echo/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
"$source": "argv",
"index": 0
}
},
"createGitHash": {
"type": "boolean",
"description": "Create a git hash.",
"default": false
}
},
"required": []
Expand Down

0 comments on commit 751fdad

Please sign in to comment.