Skip to content

Commit

Permalink
feat: beforeWriteFiles
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Feb 15, 2023
1 parent d00b7d4 commit cc12c24
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,9 @@ ${routesExport}
async function _writeConfigFiles() {
log('💾 writing...')

// TODO: extendRoutes
// const editable = new EditableTreeNode(routeTree)
if (options.beforeWriteFiles) {
await options.beforeWriteFiles(editableRoutes)
}

logTree(routeTree, log)
if (dts) {
Expand Down
8 changes: 8 additions & 0 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ export interface ResolvedOptions {
*/
extendRoute?: (route: EditableTreeNode) => Awaitable<void>

/**
* Allows to do some changes before writing the files. This will be invoked **every time** the files need to be written.
*
* @param rootRoute - {@link EditableTreeNode} of the root route
* @returns
*/
beforeWriteFiles?: (rootRoute: EditableTreeNode) => Awaitable<void>

/**
* Enables EXPERIMENTAL data fetching. See https://github.com/posva/unplugin-vue-router/tree/main/src/data-fetching
*/
Expand Down

0 comments on commit cc12c24

Please sign in to comment.