import fs from "fs/promises"; import { mkdir_to, exec_i } from "../lib/builderator.js"; import { log } from "../lib/logging.js"; export const BANDO_GIT = "https://git.learnjsthehardway.com/learn-javascript-the-hard-way/ljsthw-bandolier.git"; export const description = "Test command."; export const options = [ ["--repo", "repository to dupe and setup", BANDO_GIT], ]; export const argument = ["", "name of the project"]; export const main = async (target, opts) => { // cloning force is an odd feature that's much more complex // https://stackoverflow.com/questions/2411031/how-do-i-clone-into-a-non-empty-directory try { await fs.access(target); log.error(`Target ${target} exists. Won't install into it.`); process.exit(1); } catch(error) { // access is stupid, it throws an exception but we want the negative response as a positive outcome exec_i(`git clone --depth 1 ${BANDO_GIT} ${target}`); process.exit(0); } }