appDir
This commit is contained in:
parent
88640d7acf
commit
0202ebb217
|
|
@ -5,7 +5,7 @@ import { join, extname } from "path"
|
|||
import type { CommandOutput } from "app/src/shared/types"
|
||||
import { NOSE_WWW } from "app/src/config"
|
||||
import { getState } from "@/session"
|
||||
import { appPath } from "app/src/webapp"
|
||||
import { appDir } from "app/src/webapp"
|
||||
import { isBinaryFile } from "app/src/utils"
|
||||
import { highlight } from "../lib/highlight"
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ export default async function (path: string) {
|
|||
const project = state.project
|
||||
if (!project) return { error: "no project loaded" }
|
||||
|
||||
const root = appPath(project)
|
||||
const root = appDir(project)
|
||||
if (!root) return { error: "error loading project" }
|
||||
|
||||
let files: string[] = []
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { join, extname } from "path"
|
|||
import type { CommandOutput } from "app/src/shared/types"
|
||||
import { NOSE_WWW } from "app/src/config"
|
||||
import { getState } from "@/session"
|
||||
import { appPath } from "app/src/webapp"
|
||||
import { appDir } from "app/src/webapp"
|
||||
import { isBinaryFile } from "app/src/utils"
|
||||
import { countChar } from "app/src/shared/utils"
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ export default async function (path: string) {
|
|||
const project = state.project
|
||||
if (!project) return { error: "no project loaded" }
|
||||
|
||||
const root = appPath(project)
|
||||
const root = appDir(project)
|
||||
if (!root) return { error: "error loading project" }
|
||||
|
||||
let files: string[] = []
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { readdirSync } from "fs"
|
||||
import { NOSE_WWW } from "app/src/config"
|
||||
import { getState } from "@/session"
|
||||
import { appPath } from "app/src/webapp"
|
||||
import { appDir } from "app/src/webapp"
|
||||
|
||||
export default function () {
|
||||
const state = getState()
|
||||
|
|
@ -10,7 +10,7 @@ export default function () {
|
|||
const project = state.project
|
||||
if (!project) return { error: "no project loaded" }
|
||||
|
||||
const root = appPath(project)
|
||||
const root = appDir(project)
|
||||
if (!root) return { error: "error loading project" }
|
||||
|
||||
let files: string[] = []
|
||||
|
|
|
|||
|
|
@ -33,20 +33,19 @@ export function apps(): string[] {
|
|||
return apps.sort()
|
||||
}
|
||||
|
||||
export function appPath(name: string): string | undefined {
|
||||
export function appDir(name: string): string | undefined {
|
||||
const path = [
|
||||
`${name}.ts`,
|
||||
`${name}.tsx`,
|
||||
join(name, "index.ts"),
|
||||
join(name, "index.tsx")
|
||||
name
|
||||
]
|
||||
.map(path => join(NOSE_WWW, path))
|
||||
.flat()
|
||||
.filter(path => isFile(path))[0]
|
||||
.filter(path => /\.tsx?$/.test(path) ? isFile(path) : isDir(path))[0]
|
||||
|
||||
if (!path) return
|
||||
|
||||
return dirname(path)
|
||||
return /\.tsx?$/.test(path) ? dirname(path) : path
|
||||
}
|
||||
|
||||
async function findApp(name: string): Promise<App | undefined> {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user