🚀 Socket Launch Week 🚀 Day 5: Introducing Socket Fix.Learn More
Socket
Sign inDemoInstall
Socket

git-cli-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

git-cli-wrapper - npm Package Compare versions

Comparing version

to
0.2.0

LICENSE

11

dist/index.d.ts

@@ -11,3 +11,3 @@ export interface RunOptions {

export interface Logger {
info(message?: any, ...params: any[]): void;
trace(message?: any, ...params: any[]): void;
debug(message?: any, ...params: any[]): void;

@@ -20,2 +20,3 @@ [key: string]: any;

private logger;
private start;
readonly dir: string;

@@ -30,3 +31,9 @@ constructor(dir: string, options?: GitOptions);

getBranch(): Promise<string>;
private startLog;
private endLog;
}
export default function git(dir: string, options?: GitOptions): Git;
declare function git(dir: string, options?: GitOptions): Git;
declare namespace git {
var logger: any;
}
export default git;

18

dist/index.js

@@ -8,3 +8,2 @@ "use strict";

constructor(dir, options = {}) {
this.logger = console;
this._dir = dir;

@@ -18,4 +17,3 @@ this.name = path.basename(dir);

async run(args, options = {}) {
this.logger && this.logger.info(`${this.name} run command: ${args.join(' ')}`);
const start = new Date();
this.startLog(args);
const proc = execa('git', args, {

@@ -30,3 +28,3 @@ cwd: this._dir,

const result = await proc;
this.logger && this.logger.debug('command: %s, duration: %s, exit code: %s, output: %s', chalk_theme_1.default.info(args[0]), chalk_theme_1.default.info((new Date().getMilliseconds() - start.getMilliseconds()).toString() + 'ms'), chalk_theme_1.default.info(result.exitCode.toString()), result.all);
this.endLog(args, result);
if (options.trimEnd === false) {

@@ -38,2 +36,3 @@ return result.all;

catch (e) {
this.endLog(args, e);
if (!options.mute) {

@@ -58,7 +57,18 @@ throw e;

}
startLog(args) {
this.logger && this.logger.debug(`${this.name} run command: ${args.join(' ')}`);
this.start = new Date();
}
endLog(args, result) {
this.logger && this.logger.trace('command: %s, duration: %s, exit code: %s, output: %s', chalk_theme_1.default.info(args[0]), chalk_theme_1.default.info((new Date().getMilliseconds() - this.start.getMilliseconds()).toString() + 'ms'), chalk_theme_1.default.info(result.exitCode.toString()), result.all);
}
}
exports.Git = Git;
function git(dir, options = {}) {
if (typeof options.logger === 'undefined') {
options.logger = git.logger;
}
return new Git(dir, options);
}
git.logger = null;
exports.default = git;
{
"name": "git-cli-wrapper",
"version": "0.1.5",
"version": "0.2.0",
"description": "Git cli wrapper",

@@ -24,3 +24,3 @@ "keywords": [

"scripts": {
"build": "tsc",
"build": "yarn clean && tsc",
"clean": "rimraf dist coverage",

@@ -32,3 +32,3 @@ "test": "jest",

"@types/node": "^12.7.3",
"chalk-theme": "^0.1.5",
"chalk-theme": "^0.2.0",
"execa": "^2.0.0"

@@ -45,3 +45,3 @@ },

},
"gitHead": "0d728b95f521b9c12996b39c7065656d34e281b4"
"gitHead": "50907c49de055c79a925721aa7cb59a1b11d4869"
}