This is only for testing npm init for installing other things.
https://learnjsthehardway.com/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
969 B
28 lines
969 B
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 = ["<target>", "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);
|
|
}
|
|
}
|
|
|