projex
Version:
A command line to manage the workflow
38 lines (37 loc) • 1.31 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CloneUtils = void 0;
const _api_1 = require("../../../../api/index");
const _shared_1 = require("../../../../shared/index");
const chalk_1 = __importDefault(require("chalk"));
const fs = require('fs');
class CloneUtils {
repositoryUrl;
root;
constructor(repositoryUrl) {
this.repositoryUrl = repositoryUrl;
this.root = (0, _api_1.getCurrentDirectory)();
}
cloneRepository = (repository) => {
try {
_shared_1.log.info(`cloning repository ${chalk_1.default.bold(repository)}...`);
return (0, _shared_1.runCommand)(`git clone ${this.repositoryUrl}${repository}`, this.root, 'Cloned');
}
catch (e) {
_shared_1.log.error(`${_api_1.Colors.ERROR('an error occurred while cloning the repository')} ${chalk_1.default.bold(repository)}.`);
_shared_1.log.error(e);
}
};
checkDirectory = (repository) => {
try {
return fs.existsSync(repository);
}
catch (error) {
return false;
}
};
}
exports.CloneUtils = CloneUtils;