import fs from "fs";
import isogit from "isomorphic-git";
import http from "isomorphic-git/http/node";

const clone = async (options: {
	from: string;
	to: string;
	auth?: string;
}) => {
	fs.mkdirSync(options.to, {recursive: true});
	await isogit.clone({
		fs,
		http,
		onAuth() {
			return {
				username: 'x-access-token',
				password: options.auth,
			}
		},
		dir: options.to,
		url: options.from,
	});
}

export const git = {
	clone,
}