2 years ago
#99493

Sam Herrmann
How to commit changes to Git in Angular Schematic
I would like my Angular Schematic for ng add to automatically commit its changes to Git. Adding a Rule to commit the changes to Git after all my other Rules doesn't work properly because it executes too early and misses most of the changes:
export function ngAdd(): Rule {
return chain([
/* all my rules */
gitCommit()
]);
}
function gitCommit(message: string): Rule {
return () => {
execSync(`git add .`).toString();
execSync(`git commit -m "${message}"`).toString();
}
}
It makes sense that this doesn't work because Rules make changes to the Tree and not directly on the file system. Therefore, the Rule returned by gitCommit() would execute before the changes from the previous Rules are applied to the file system.
Question
How can I run a task after the transformed Tree is applied to the file system within the Schematic?
angular
angular-schematics
angular
angular-schematics
0 Answers
Your Answer