readmeq v1.3.0
readmeq
Just another one solution for modifying your
README.md
(not only) file.
Can be useful if you want to modify some parts of your README.md
(not only) file on any step of build
, commit
, pre-comit
, etc.
Usage:
- put some sections to any place of your
README.md
file like this:
<!--READMEQ:someKey-->someData<!--/READMEQ:someKey-->
or like this:
<!--READMEQ:someKey-->
any **data** _between_
and <a href="https://kostix.dev">anything</a> else
<!--/READMEQ:someKey-->
- use
modifyReadmeqSingle
method like this:
await modifyReadmeqSingle('someKey', 'someOtherData(MODIFIED)', { n : true });
- the result in your file will be:
<!--READMEQ:someKey-->
someOtherData(MODIFIED)
<!--/READMEQ:someKey-->
Documantation:
Check documentation here
Type Aliases
Functions
Type Aliases
BackupOptions
Ƭ BackupOptions: Object
Backup options.
Type declaration
Name | Type | Description |
---|---|---|
backupSuffix | string | backup file suffix (file.ext => file${backupSuffix}.ext ) Default _backup${Date.now()} |
backupSuffixMatch | string | backup file suffing pattern (RegEx ), where ([0-9]+) - uniq time-based integer (!important) id of its backup version Default _backup([0-9]+) |
backupsPath | string | projects base/root path Default ${path.join(basePath,'.readmeqBackups')} |
basePath | string | projects base/root path Default ${process.cwd()} |
Defined in
FilePath
Ƭ FilePath: string
filePath data type (string)
Defined in
ModifyOptions
Ƭ ModifyOptions: Object
Modify options.
Type declaration
Name | Type | Description |
---|---|---|
backup | boolean | apply backupReadmeq method mefore modifying Default ts false |
backupOptions | BackupOptions | applying to backupReadmeq method if backup=true Default ts backupOptions |
filePath | string | path to modified file Default ts './README.md' |
n | boolean | insert newData from new line (\n on start/end) Default ts false |
sectionEnd | string | section end pattern, where KEY_NAME (!important) - your section key Default ts '<!--/READMEQ:KEY_VALUE-->' |
sectionStart | string | section start pattern, where KEY_NAME (!important) - your section key Default ts '<!--READMEQ:KEY_VALUE-->' |
Defined in
Result
Ƭ Result<T
>: { status
: "ok"
; value
: T
} | { error
: Error
; status
: "error"
}
Result to return
Type parameters
Name | Description |
---|---|
T | value type of status: 'ok' |
Defined in
Functions
backupReadmeq
▸ backupReadmeq(filePath
, options?
): Promise
<Result
<string
>>
Backup readmeq modified file. Use this method when its important to have previous versions of modified file. Or any other cases when its needed. Use this method on your own risk.
Parameters
Name | Type | Description |
---|---|---|
filePath | string | path to file |
options? | Partial <BackupOptions > | - |
Returns
Promise
<Result
<string
>>
backup file path (or throw some error)
Async
Defined in
modifyReadmeqSingle
▸ modifyReadmeqSingle(key
, newData
, options?
): Promise
<Result
<boolean
>>
Modify single key
section.
Parameters
Name | Type | Description |
---|---|---|
key | string | section key |
newData | string | section data |
options? | Partial <ModifyOptions > | - |
Returns
Promise
<Result
<boolean
>>
file modified (or throw some error)
Async
Defined in
restoreReadmeqFromPath
▸ restoreReadmeqFromPath(filePath
, backupFilePath
, backupBeforeRestore?
, options?
): Promise
<Result
<boolean
>>
Restore version of readmeq modified file from specific path. Use this method on your own risk.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
filePath | string | undefined | path to file |
backupFilePath | string | undefined | path to its backup file |
backupBeforeRestore | boolean | true | - |
options? | Partial <BackupOptions > | undefined | - |
Returns
Promise
<Result
<boolean
>>
file restored (or throw some error)
Async
Defined in
restoreReadmeqLatest
▸ restoreReadmeqLatest(filePath
, backupBeforeRestore?
, options?
): Promise
<Result
<boolean
>>
Restore latest version of readmeq modified file. Based on its backup suffix. Use this method on your own risk.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
filePath | string | undefined | path to file |
backupBeforeRestore | boolean | true | - |
options? | Partial <BackupOptions > | undefined | - |
Returns
Promise
<Result
<boolean
>>
file restored (or throw some error)
Async
Defined in
TODO:
- mk mass modifying
- move backup/restore to separate module