First sort of working isntaller.

master
Zed A. Shaw 2 years ago
parent 06212d993a
commit f0421a2976
  1. 19
      commands/create.js

@ -2,14 +2,27 @@ 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 = [
["--force", "obliterate files in the target directory", false]
["--repo", "repository to dupe and setup", BANDO_GIT],
];
export const argument = ["<string>", "name of the project"];
export const argument = ["<target>", "name of the project"];
export const main = async (opts) => {
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);
}
}

Loading…
Cancel
Save