feat(runner): add readme command
This commit is contained in:
@@ -31,6 +31,10 @@ $ node runner.js init {operator_name}
|
|||||||
To initialize folder and config file for an operator
|
To initialize folder and config file for an operator
|
||||||
```
|
```
|
||||||
``` bash
|
``` bash
|
||||||
|
$ node runner.js readme {operator_name}
|
||||||
|
To add operator info to README.md
|
||||||
|
```
|
||||||
|
``` bash
|
||||||
$ node runner.js directory
|
$ node runner.js directory
|
||||||
To generate directory.json
|
To generate directory.json
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export async function read(filePath, encoding = 'utf8') {
|
|||||||
return await fsP.readFile(filePath, encoding, { flag: 'r' })
|
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' })
|
return fs.readFileSync(filePath, encoding, { flag: 'r' })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,6 +50,6 @@ export async function copy(sourcePath, targetPath) {
|
|||||||
return await fsP.copyFile(sourcePath, targetPath)
|
return await fsP.copyFile(sourcePath, targetPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
function append(content, filePath) {
|
export function appendSync(content, filePath) {
|
||||||
|
return fs.appendFileSync(filePath, content, 'utf8');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
|
import path from 'path'
|
||||||
|
import { appendSync, readSync } from './file.js'
|
||||||
|
|
||||||
export function append(config, operatorName, rootDir) {
|
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 |
Reference in New Issue
Block a user