|
1 | 1 | import {readFileSync, writeFileSync} from 'fs'; |
2 | 2 | import fileExists from 'node-file-exists'; |
3 | 3 | import {red} from 'chalk'; |
| 4 | +import {join} from 'path'; |
4 | 5 |
|
5 | | -export function createReadme(): boolean { |
| 6 | +export function createReadme(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 | return false; |
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 | return false; |
15 | 16 | } |
16 | | - let data: CR.Output = JSON.parse(readFileSync('coderoad.json', 'utf8')); |
17 | | - let packageJson: PackageJson = JSON.parse(readFileSync('package.json', 'utf8')); |
| 17 | + let data: CR.Output = JSON.parse(readFileSync(join(dir, 'coderoad.json'), 'utf8')); |
| 18 | + let packageJson: PackageJson = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8')); |
18 | 19 | let content: string = generateReadme(data, packageJson); |
19 | | - writeFileSync('README.md', content, 'utf8'); |
| 20 | + writeFileSync(join(dir, 'README.md'), content, 'utf8'); |
20 | 21 | return true; |
21 | 22 | } |
22 | 23 |
|
|
0 commit comments