This project is a task based mechanism which enables you to run tasks, providing custom functionality in prebuild stage. It is designed as a submodule to use in various projects.
In order to use this in your project, you should import ./index.js use and
use the run() function;
await run("path/to/your/config.yml", { customTasks });The function reads your configuration from the provided .yml file and
asyncrounusly runs the tasks with given configurations.
To add this package to your repository and include below in your package.json
"devDependencies": {
"@mouseless/prebuild": "github:mouseless/prebuild"
}
Below is sample configuration which you can copy and use. Before you run your app, make sure you correctly change the projectRoot value accordingly.
# Project root relative to this config file
# This is required
projectRoot: ../../
# Log settings
log:
debug: false # Enable debug logs
quiet: false # Disable logs completely
# Tasks run in given order, you can change the order according to your needs
tasks:
- clean:
directories:
- ./.theme/.temp
- ./.theme/.output
- copy:
extension: .png # optional
source: ./
target: ./.theme/.public
- indent:
source: ./.theme/content
- move:
extension: .png # optional
source: ./.theme/.temp
target: ./.theme/.public
- rename:
source: ./.theme/.temp
find: README.md
replace: index.md
- replaceContent:
extension: .md
source: ./.theme/.temp
oldText: README.md
newText: index.md
- touch:
path: ./.theme/.env.localThis task (.theme/prebuild/tasks/clean.js) deletes files with the given
parameters, including subfolders.
This task (.theme/prebuild/tasks/copy.js) copies files with the given
extension to the desired location.
This task (.theme/prebuild/tasks/indent.js) adjusts the indentation of
components defined in the MDC format in the Markdown files in the target
directory.
This task (.theme/prebuild/tasks/move.js) moves files with given extension
from source directory to target directory.
This task (.theme/prebuild/tasks/rename.js) renames files with the given
name in the given location to the desired name in the same location.
This task (.theme/prebuild/tasks/replaceContent.js) replaces given old text
to new text in files with given extension. We used this one to replace
README.md with index.md before fixing links.
This task (.theme/prebuild/tasks/touch.js) checks whether file with a given
path exists, if not, it creates an empty file at the specified path.