galbe 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/cli.ts +9 -12
  2. package/package.json +1 -1
package/bin/cli.ts CHANGED
@@ -1,13 +1,12 @@
1
1
  #!/usr/bin/env bun
2
2
 
3
- import { $ } from 'bun'
3
+ import { $, Glob } from 'bun'
4
4
  import type { RouteMeta } from '../src/routes'
5
5
  import { program } from 'commander'
6
6
  import { relative, resolve } from 'path'
7
- import { mkdir, readdir, rm } from 'fs/promises'
7
+ import { mkdir, readdir, lstat, rm } from 'fs/promises'
8
8
  import { metaAnalysis } from '../src/routes'
9
9
  import { randomUUID } from 'crypto'
10
- import { glob } from 'glob'
11
10
  import { Galbe } from '../src'
12
11
 
13
12
  const ROOT = process.cwd()
@@ -19,22 +18,20 @@ const parseRoutes = async (routes?: string | string[]): Promise<{ path: string;
19
18
  if (!routes) return []
20
19
  let files: { path: string; meta: RouteMeta }[] = []
21
20
  if (typeof routes === 'string') {
22
- let filePaths = await glob(routes, { cwd: ROOT, withFileTypes: true, ignore: 'node_modules/**' })
23
- for (const file of filePaths.map(f => ({ name: f.name, path: f.path, type: f.getType() }))) {
24
- const path = `${file.path}/${file.name}`
25
- if (file.type === 'File') files.push({ path, meta: await metaAnalysis(path) })
26
- else if (file.type === 'Directory') {
21
+ for await (const path of new Glob(routes).scan({ cwd: ROOT, absolute: true, onlyFiles: false })) {
22
+ const isDir = (await lstat(path)).isDirectory()
23
+ if (isDir) {
27
24
  files = files.concat(
28
25
  await Promise.all(
29
26
  (
30
- await readdir(`${file.path}/${file.name}`)
27
+ await readdir(path)
31
28
  ).map(async f => ({
32
- path: `${file.path}/${f}`,
33
- meta: await metaAnalysis(`${file.path}/${f}`)
29
+ path: f,
30
+ meta: await metaAnalysis(path)
34
31
  }))
35
32
  )
36
33
  )
37
- }
34
+ } else files.push({ path, meta: await metaAnalysis(path) })
38
35
  }
39
36
  }
40
37
  if (Array.isArray(routes)) for (const r of routes) files = files.concat(await parseRoutes(r))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "galbe",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Fast, lightweight and highly customizable JavaScript web framework based on Bun",
5
5
  "author": "Pierre Caillaud M (https://github.com/pierre-cm)",
6
6
  "type": "module",