feat(runner): add readme command

This commit is contained in:
Haoyu Xu
2023-01-17 20:47:08 -05:00
parent 61e5ffd214
commit f067e8f194
6 changed files with 15 additions and 5 deletions

View File

@@ -31,6 +31,10 @@ $ node runner.js init {operator_name}
To initialize folder and config file for an operator
```
``` bash
$ node runner.js readme {operator_name}
To add operator info to README.md
```
``` bash
$ node runner.js directory
To generate directory.json
```

View File

@@ -15,7 +15,7 @@ export async function read(filePath, encoding = 'utf8') {
return await fsP.readFile(filePath, encoding, { flag: 'r' })
}
export async function readSync(filePath, encoding = 'utf8') {
export function readSync(filePath, encoding = 'utf8') {
return fs.readFileSync(filePath, encoding, { flag: 'r' })
}
@@ -50,6 +50,6 @@ export async function copy(sourcePath, targetPath) {
return await fsP.copyFile(sourcePath, targetPath)
}
function append(content, filePath) {
export function appendSync(content, filePath) {
return fs.appendFileSync(filePath, content, 'utf8');
}

View File

@@ -1,5 +1,11 @@
import path from 'path'
import { appendSync, readSync } from './file.js'
export function append(config, operatorName, rootDir) {
const operatorConfig = config.operators[operatorName]
const projectJson = JSON.parse(readSync(path.join(rootDir, config.folder.operator, operatorName, 'project.json')))
appendSync(
`\n| ${operatorConfig.title.split(' - ')[0].split('Arknights: ')[1]} | [Link](https://arknights.halyul.dev/${operatorConfig.link}/) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=${projectJson.workshopid}) |`,
path.join(rootDir, 'README.md')
)
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB