New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lint-prepush

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lint-prepush - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

10

index.js

@@ -12,3 +12,3 @@ #!/usr/bin/env node

const chalk = require("chalk");
const debug = require("debug")("index");
const debug = require("debug")("lint-prepush:index");

@@ -24,7 +24,9 @@ const success = chalk.keyword("green");

loadConfig()
.then(({ config = [] }) => {
.then(({ config = {} } = {}) => {
let { base : baseBranch = 'master', tasks = {} } = config;
debug('Base Branch:' + baseBranch);
// Fetching committed git files
fetchGitDiff().then((committedGitFiles = []) => {
fetchGitDiff( baseBranch ).then((committedGitFiles = []) => {
debug(committedGitFiles);
new Listr(resolveMainTask({ config, committedGitFiles }), {
new Listr(resolveMainTask({ tasks, committedGitFiles }), {
exitOnError: false,

@@ -31,0 +33,0 @@ concurrent: true

2

package.json
{
"name": "lint-prepush",
"version": "0.0.2",
"version": "0.1.0",
"description": "Run linters on committed files in a Branch🔬",

@@ -5,0 +5,0 @@ "author": "“Theenadayalan” <“puduvai.theena@gmail.com”>",

@@ -1,2 +0,2 @@

# lint-prepush
# lint-prepush [![npm version](https://badge.fury.io/js/lint-prepush.svg)](https://badge.fury.io/js/lint-prepush) [![GitHub license](https://img.shields.io/github/license/theenadayalank/lint-prepush.svg)](https://github.com/theenadayalank/lint-prepush/blob/master/LICENSE)

@@ -55,5 +55,8 @@ > Run linters on committed files in a Branch🔬

+ "lint-prepush": {
+ "*.js": [
+ "eslint"
+ ]
+ "base": "master",
+ "tasks": {
+ "*.js": [
+ "eslint"
+ ]
+ }
+ }

@@ -100,2 +103,2 @@ }

MIT @ [Theena Dayalan](https://www.theenadayalan.me/)
MIT @ [Theena Dayalan](https://www.theenadayalan.me/)

@@ -6,8 +6,8 @@ const chalk = require("chalk");

module.exports = function fetchGitDiff(origin = "master") {
// git command to push out the changed file names between current branch and master (Exclude delelted files which cannot be fetched now)
let command = `git diff --name-only --diff-filter=d ${origin} HEAD`;
module.exports = function fetchGitDiff( baseBranch = "master" ) {
// git command to pull out the changed file names between current branch and master (Exclude delelted files which cannot be fetched now)
let command = `git diff --name-only --diff-filter=d ${baseBranch}...HEAD`;
return new Promise(resolve => {
spawnChildProcess({ command }, ({ hasErrors, output }) => {
spawnChildProcess({ command }, ({ hasErrors = false, output = {} }) => {
let fileList = [];

@@ -17,16 +17,13 @@ if (hasErrors) {

warning(
`Fetching GIT diff process closed with errors: \n ${output.stderr}`
`Fetching commited files process closed with errors: \n ${output.stderr}`
)
);
resolve(fileList);
} else {
output.stdout.split("\n").forEach(filename => {
if (filename) {
fileList.push(filename);
}
filename ? fileList.push(filename) : null;
});
resolve(fileList);
}
resolve(fileList);
});
});
};

@@ -8,3 +8,3 @@ const Listr = require("listr");

module.exports = function resolveMainTask(options) {
module.exports = function resolveMainTask( options = {} ) {
return constructTaskList(options).map(task => ({

@@ -26,6 +26,6 @@ title: `Linting ${task.fileFormat} files`,

function constructTaskList({ config, committedGitFiles }) {
return Object.keys(config).map(fileFormat => {
function constructTaskList({ tasks = {}, committedGitFiles = [] } = {}) {
return Object.keys(tasks).map(fileFormat => {
let fileList = [];
let commandList = config[fileFormat];
let commandList = tasks[fileFormat];
fileList = micromatch(committedGitFiles, [fileFormat], {

@@ -32,0 +32,0 @@ matchBase: true,

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