UNPKG

jenkins-cli-node

Version:
68 lines 2.39 kB
"use strict"; /** @format */ 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()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const chalk_1 = require("chalk"); const path = require("path"); const Git = require("simple-git/promise"); const notifier = require("node-notifier"); const fs_extra_1 = require("fs-extra"); const js_yaml_1 = require("js-yaml"); const config_1 = require("../config"); const git = Git(); exports.resolve = (p) => { return path.resolve(p); }; exports.alert = (title, message, clickFun) => { notifier.notify({ title, message, icon: path.join(config_1.ROOT_PATH, '../public/jenkins.png'), timeout: 3 }); if (clickFun) { notifier.on('click', (notifierObject, options, event) => { clickFun(); }); } }; exports.sleep = (timeout) => { return new Promise(resolve => { setTimeout(resolve, timeout); }); }; exports.printSuccess = msg => { console.log(); console.log(chalk_1.default.green(msg)); }; exports.printInfo = msg => { console.log(); console.log(chalk_1.default.blue(msg)); console.log(); }; exports.printError = (msg) => { // console.error(msg) console.log(); console.log(chalk_1.default.bgRed(msg)); console.log(); }; exports.loadYaml = (path) => { if (!fs_extra_1.existsSync(path)) { throw new Error('no such file or directory'); } const yamlFile = fs_extra_1.readFileSync(path, 'utf8'); return js_yaml_1.safeLoad(yamlFile); }; exports.getBranchByRemote = (url) => __awaiter(void 0, void 0, void 0, function* () { const branch = yield git.listRemote(["--heads", url]); return branch.match(/refs\/heads\/(\S+)/g) || []; }); //# sourceMappingURL=index.js.map