@@ -4,23 +4,25 @@ import * as path from "path";
44import { Node , Edge , Graph , Link , LinkType , NodeShape , ArrowType } from "./types" ;
55import { FileLink } from "./types" ;
66
7- const graph = getGQMFileLinks ( ) ;
7+ const mdFilePath = process . env . npm_config_markDownFilePath || "../../measuring" ;
8+
9+ const graph = getGQMFileLinks ( mdFilePath ) ;
810
911export function getLinkUrl ( linkType : LinkType , file : string ) {
1012 const measuringUrl = "https://github.com/InnerSourceCommons/managing-inner-source-projects/blob/main/measuring/" ;
1113 const url = `${ measuringUrl } /${ linkType . toLowerCase ( ) } s/${ file } `
1214 return url ;
1315}
1416
15- export function getGQMFileLinks ( ) {
17+ export function getGQMFileLinks ( mdFilePath : string ) {
1618 const graph : Graph = {
1719 nodes : [ ] ,
1820 edges : [ ] ,
1921 } ;
2022
21- const goalsPath = "../../measuring/ goals/" ;
22- const questionsPath = "../../measuring/ questions/" ;
23- const metricsPath = "../../measuring/ metrics/" ;
23+ const goalsPath = ` ${ mdFilePath } / goals/` ;
24+ const questionsPath = ` ${ mdFilePath } / questions/` ;
25+ const metricsPath = ` ${ mdFilePath } / metrics/` ;
2426
2527 const goalFileLinks : FileLink [ ] = getFileLinks ( LinkType . GOAL , goalsPath ) ;
2628 appendToGraph ( graph , goalFileLinks ) ;
@@ -144,8 +146,7 @@ export function generateMermaidDiagram(graph: Graph) {
144146 const nodes = graph . nodes ;
145147 const edges = graph . edges ;
146148
147- let mermaidSyntax = `\`\`\`mermaid\n
148- graph LR;\n
149+ let mermaidSyntax = `\`\`\`mermaid\ngraph LR;\n
149150 subgraph GQM[Goals, Questions, Metrics]\n
150151 ` ;
151152
@@ -156,7 +157,7 @@ export function generateMermaidDiagram(graph: Graph) {
156157
157158 edges . forEach ( ( edge ) => {
158159 const arrowSyntax : string = ArrowType . ARROW ;
159- mermaidSyntax += `${ edge . from } ${ arrowSyntax } ${ edge . to } \n` ;
160+ mermaidSyntax += ` ${ edge . from } ${ arrowSyntax } ${ edge . to } \n` ;
160161 } ) ;
161162
162163 const goalsList = nodes . filter ( n => n . type == LinkType . GOAL ) . map ( n => `${ n . id } ` ) . join ( ',' ) ;
0 commit comments