use super::{DetectResult, ProjectDef};
use std::path::Path;

use anyhow::Result;

pub const DEF: ProjectDef = ProjectDef {
    name: "nuxt",
    detect: detect,
    build_cmd: &["npm", "run", "build"],
    run_cmd: &["node", ".output/server/index.mjs"],
};

fn detect(dir: &Path) -> Result<DetectResult> {
    let matched = dir.join("nuxt.config.ts").exists()
        || dir.join("nuxt.config.js").exists();
    Ok(if matched { DetectResult::matched() } else { DetectResult::no_match() })
}
