Skip to content

Commit

Permalink
🚑 UPDATE: stats only at start
Browse files Browse the repository at this point in the history
  • Loading branch information
jycouet committed Nov 27, 2023
1 parent 59c5159 commit 779a76b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/hip-cars-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'vite-plugin-kit-routes': patch
---

stats only at start
13 changes: 7 additions & 6 deletions packages/vite-plugin-kit-routes/src/lib/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ const arrayToRecord = (arr?: string[]) => {
return `: Record<string, never>`
}

export const run = (o?: Options) => {
export const run = (atStart: boolean, o?: Options) => {
const options = getDefaultOption(o)

let files = getFilesUnder(routes_path())
Expand Down Expand Up @@ -820,11 +820,11 @@ ${objTypes

if (shouldLog('update', options)) {
child.on('close', code => {
theEnd(result, objTypes, options)
theEnd(atStart, result, objTypes, options)
})
}
} else {
theEnd(result, objTypes, options)
theEnd(atStart, result, objTypes, options)
}
return true
}
Expand All @@ -833,6 +833,7 @@ ${objTypes
}

function theEnd(
atStart: boolean,
result: boolean,
objTypes: { type: KindOfObject; files: MetadataToWrite[] }[],
o: Options,
Expand All @@ -843,7 +844,7 @@ function theEnd(
log.success(`${yellow(options.generated_file_path)} updated`)
}

if (shouldLog('stats', options)) {
if (atStart && shouldLog('stats', options)) {
const stats = []
let nbRoutes = objTypes.flatMap(c => c.files).length
stats.push(
Expand Down Expand Up @@ -915,7 +916,7 @@ export function kitRoutes<T extends ExtendTypes = ExtendTypes>(options?: Options
{
name: 'kit-routes',
configureServer() {
run(options)
run(true, options)
},
},

Expand All @@ -926,7 +927,7 @@ export function kitRoutes<T extends ExtendTypes = ExtendTypes>(options?: Options
logs: [],
watch: ['**/+page.svelte', '**/+page.server.ts', '**/+server.ts'],
run: () => {
run(options)
run(false, options)
},
},
]),
Expand Down
14 changes: 7 additions & 7 deletions packages/vite-plugin-kit-routes/src/lib/plugins.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ describe('run()', async () => {
//
// 'object[path]'
const generated_file_objectPath = 'src/test/ROUTES_format-object-path.ts'
run({
run(false, {
format: 'object[path]',
generated_file_path: generated_file_objectPath,
...commonConfig,
Expand All @@ -395,7 +395,7 @@ describe('run()', async () => {

// 'object[symbol]'
const generated_file_objectSymbol = 'src/test/ROUTES_format-object-symbol.ts'
run({
run(false, {
generated_file_path: generated_file_objectSymbol,
format: 'object[symbol]',
...commonConfig_symbol,
Expand All @@ -404,7 +404,7 @@ describe('run()', async () => {

// 'route(path)'
const generated_file_routePath = `src/test/ROUTES_format-route-path.ts`
run({
run(false, {
generated_file_path: generated_file_routePath,
format: 'route(path)',
...commonConfig,
Expand All @@ -413,7 +413,7 @@ describe('run()', async () => {

// 'route(symbol)'
const generated_file_routeSymbol = 'src/test/ROUTES_format-route-symbol.ts'
run({
run(false, {
generated_file_path: generated_file_routeSymbol,
format: 'route(symbol)',
...commonConfig,
Expand All @@ -422,7 +422,7 @@ describe('run()', async () => {

// 'variables'
const generated_file_variables = 'src/test/ROUTES_format-variables.ts'
run({
run(false, {
generated_file_path: generated_file_variables,
format: 'variables',
...commonConfig_symbol,
Expand Down Expand Up @@ -482,7 +482,7 @@ describe('run()', async () => {

it('post_update_run', () => {
const generated_file_path = 'src/test/ROUTES_post-update.ts'
run({
run(false, {
generated_file_path,
post_update_run: 'echo done',
})
Expand All @@ -492,7 +492,7 @@ describe('run()', async () => {

it('with path base', () => {
const generated_file_path = 'src/test/ROUTES_base.ts'
run({
run(false, {
generated_file_path,
path_base: true,
})
Expand Down

1 comment on commit 779a76b

@vercel
Copy link

@vercel vercel bot commented on 779a76b Nov 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

kitql – ./

kitql-git-main-jycouet.vercel.app
www.kitql.dev
kitql-jycouet.vercel.app
kitql.dev
kitql.vercel.app

Please sign in to comment.