@@ -3,8 +3,9 @@ import * as validate from './validators';
33import { info } from './parser/info' ;
44import { createReadme } from './readme' ;
55import { cleanup } from './parser/cleanup' ;
6+ import { join } from 'path' ;
67
7- function parseAndBuild ( lines : string [ ] ) : CR . Output {
8+ function parseAndBuild ( dir : string , lines : string [ ] ) : CR . Output {
89 // coderoad.json outline
910 const result : CR . Output = {
1011 info : {
@@ -17,10 +18,13 @@ function parseAndBuild(lines: string[]): CR.Output {
1718 page : - 1 ,
1819 task : - 1 ,
1920 } ;
20- return info ( result , lines , index ) ;
21+ return info ( dir , result , lines , index ) ;
2122}
2223
23- export default function build ( filePath : string , output = './coderoad.json' ) : boolean {
24+ export default function build ( dir : string , filePath : string , output = './coderoad.json' ) : boolean {
25+
26+ filePath = join ( dir , filePath ) ;
27+ output = join ( dir , output ) ;
2428
2529 // validate path name
2630 if ( ! validate . filePath ( filePath ) ) { return false ; }
@@ -29,7 +33,9 @@ export default function build(filePath: string, output = './coderoad.json'): boo
2933 const lines : string [ ] = readFileSync ( filePath , 'utf8' ) . split ( '\n' ) ;
3034
3135 // build coeroad.json
32- const result = cleanup ( parseAndBuild ( lines ) ) ;
36+ const result = cleanup ( parseAndBuild ( dir , lines ) ) ;
37+
38+ console . log ( 'result' , result ) ;
3339
3440 // error parsing or building coderoad.json
3541 if ( ! result ) { return false ; }
0 commit comments