|
1 | 1 | import{readFileSync,writeFileSync}from'fs';
|
2 | 2 | importfileExistsfrom'node-file-exists';
|
3 | 3 | import{red}from'chalk';
|
| 4 | +import{join}from'path'; |
4 | 5 |
|
5 |
| -exportfunctioncreateReadme():boolean{ |
| 6 | +exportfunctioncreateReadme(dir):boolean{ |
6 | 7 | // if (!fileExists('./README.md')) {
|
7 | 8 | // }
|
8 |
| -if(!fileExists('./coderoad.json')){ |
| 9 | +if(!fileExists(join(dir,'coderoad.json'))){ |
9 | 10 | console.log(red('No coderoad.json file found'));
|
10 | 11 | returnfalse;
|
11 | 12 | }
|
12 |
| -if(!fileExists('./package.json')){ |
| 13 | +if(!fileExists(join(dir,'package.json'))){ |
13 | 14 | console.log(red('No package.json file found'));
|
14 | 15 | returnfalse;
|
15 | 16 | }
|
16 |
| -letdata:CR.Output=JSON.parse(readFileSync('coderoad.json','utf8')); |
17 |
| -letpackageJson:PackageJson=JSON.parse(readFileSync('package.json','utf8')); |
| 17 | +letdata:CR.Output=JSON.parse(readFileSync(join(dir,'coderoad.json'),'utf8')); |
| 18 | +letpackageJson:PackageJson=JSON.parse(readFileSync(join(dir,'package.json'),'utf8')); |
18 | 19 | letcontent:string=generateReadme(data,packageJson);
|
19 |
| -writeFileSync('README.md',content,'utf8'); |
| 20 | +writeFileSync(join(dir,'README.md'),content,'utf8'); |
20 | 21 | returntrue;
|
21 | 22 | }
|
22 | 23 |
|
|