Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

waffle-server-repo-service

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

waffle-server-repo-service - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

17

index.js

@@ -6,3 +6,5 @@ "use strict";

const lodash_1 = require("lodash");
const path = require("path");
const shell = require("shelljs");
const async = require("async");
const defaultShellOptions = ['silent', 'async'];

@@ -91,9 +93,6 @@ exports.defaultOptions = {

}
getLinesAmount(options, callback) {
getLinesAmount(options, done) {
const { pathToRepo, files } = lodash_1.defaults(options, exports.defaultOptions);
let command = 'wc -l ' + pathToRepo + '/*.csv | grep "total$"';
if (lodash_1.isArray(files)) {
command = lodash_1.isEmpty(files) ? 'echo 0' : `wc -l "${files}" | grep "total$"`;
}
return this.runShellJsCommand(command, options, callback);
const pathToRepoFiles = path.resolve(pathToRepo, '*.csv');
return async.reduce(files || [pathToRepoFiles], 0, async.apply(this.getLinesAmountForFile.bind(this), options), done);
}

@@ -131,2 +130,8 @@ checkSshKey(execOptions, callback) {

}
getLinesAmountForFile(options, linesAmount, filepath, callback) {
const command = 'wc -l ' + filepath + ' | grep "total$"';
this.runShellJsCommand(command, options, (error, result) => {
return callback(error, linesAmount + result);
});
}
runShellJsCommand(command, options, callback) {

@@ -133,0 +138,0 @@ const { prettifyResult } = options;

import * as Logger from 'bunyan';
import { ChildProcess } from 'child_process';
import * as fs from 'fs';
import { defaults, includes, isArray, isEmpty, pick } from 'lodash';
import { defaults, includes, pick } from 'lodash';
import * as path from 'path';
import * as shell from 'shelljs';
import { ExecOptions } from 'shelljs';
import * as async from 'async';

@@ -169,12 +171,7 @@ export interface RSErrorCallback<T> {

public getLinesAmount(options: LinesAmountOptions, callback: RSAsyncResultCallback<any, string>): ChildProcess {
public getLinesAmount(options: LinesAmountOptions, done: RSAsyncResultCallback<any, string>): void {
const { pathToRepo, files } = defaults(options, defaultOptions);
const pathToRepoFiles = path.resolve(pathToRepo, '*.csv');
let command = 'wc -l ' + pathToRepo + '/*.csv | grep "total$"';
if (isArray(files)) {
command = isEmpty(files) ? 'echo 0' : `wc -l "${files}" | grep "total$"`;
}
return this.runShellJsCommand(command, options, callback);
return async.reduce(files || [pathToRepoFiles], 0, async.apply(this.getLinesAmountForFile.bind(this), options), done);
}

@@ -224,2 +221,10 @@

private getLinesAmountForFile(options: LinesAmountOptions, linesAmount: number, filepath: string, callback: RSAsyncResultCallback<number, string>): void {
const command = 'wc -l ' + filepath + ' | grep "total$"';
this.runShellJsCommand(command, options, (error: string, result: number): void => {
return callback(error, linesAmount + result);
});
}
private runShellJsCommand(command: string, options: Options | CloneOptions | LinesAmountOptions, callback: RSAsyncResultCallback<any, string>): ChildProcess {

@@ -226,0 +231,0 @@ const { prettifyResult } = options;

{
"name": "waffle-server-repo-service",
"version": "1.0.5",
"version": "1.0.6",
"description": "Module for working with git repos on WS and CLI tool",

@@ -50,2 +50,3 @@ "main": "index.js",

"dependencies": {
"@types/async": "^2.0.40",
"@types/bunyan": "1.8.0",

@@ -55,2 +56,3 @@ "@types/core-js": "0.9.41",

"@types/shelljs": "0.7.2",
"async": "^2.5.0",
"lodash": "4.17.4",

@@ -57,0 +59,0 @@ "path": "0.12.7",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc