UNPKG

esa-cli

Version:

A CLI for operating Alibaba Cloud ESA EdgeRoutine (Edge Functions).

53 lines (52 loc) 1.83 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { execSync } from 'child_process'; import { exit } from 'process'; export function isInstalledGit() { try { execSync('git --version'); return true; } catch (error) { return false; } } export function isGitConfigured() { try { execSync('git config --get user.name'); execSync('git config --get user.email'); return true; } catch (error) { return false; } } export function cloneRepository(url, path) { return __awaiter(this, void 0, void 0, function* () { try { execSync(`git clone ${url} ${path}`, { stdio: 'inherit' }); console.log('Repository cloned successfully.'); } catch (error) { console.error('Error occurred while cloning the repository:', error); exit(0); } }); } export function installGit(path) { try { execSync('git init', { stdio: 'inherit', cwd: path }); console.log('Git has been installed successfully.'); } catch (error) { console.error('Error occurred during Git installation:', error); exit(0); } }