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

commitplease

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commitplease - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

lib/validate.js

15

commit-msg-hook.js
#!/usr/bin/env node
require( "colors" );
var fs = require( "fs" );
var commitplease = require( "commitplease" );
var message = fs.readFileSync( process.argv[ 2 ] ).toString();
var errors = commitplease( message );
if ( errors ) {
console.error( "Invalid commit message, please fix the following issues:\n" );
console.error( "- " + errors.join( "\n- " ).red );
console.error();
console.error( "Commit message was:");
console.error();
console.error( message.green );
process.exit( 1 );
}
require( "commitplease" )( process.argv[ 2 ] );

@@ -1,38 +0,16 @@

var merge = require( "mout/object/merge" ),
defaults = {
component: true,
limits: {
subject: 50,
other: 72
}
};
module.exports = function( message, options ) {
options = merge( defaults, options );
var errors = [];
message.split(/\n/).forEach(function ( line, index ) {
if ( index === 0 ) {
if ( line.length > options.limits.subject ) {
errors.push( "First line (subject) must be no longer than " +
options.limits.subject + " characters" );
}
if ( options.component && line.indexOf( ":" ) < 1 ) {
errors.push( "First line (subject) must indicate the component " +
"(or subsystem)" );
}
}
if ( index === 1 && line.length > 0 ) {
errors.push("Second line must always be empty");
}
if ( index > 1 && line.length > options.limits.other ) {
errors.push( "Commit message line " + index + " too long: " +
line.length + " characters, only " + options.limits.other +
" allowed. Was: " + line.substring( 0, 20 ) + "[...]" );
}
});
return errors;
require( "colors" );
var fs = require( "fs" ),
validate = require( "lib/validate" );
module.exports = function( messageFile ) {
var message = fs.readFileSync( messageFile ).toString();
var errors = validate( message );
if ( errors ) {
console.error( "Invalid commit message, please fix the following issues:\n" );
console.error( "- " + errors.join( "\n- " ).red );
console.error();
console.error( "Commit message was:");
console.error();
console.error( message.green );
process.exit( 1 );
}
};

@@ -6,4 +6,2 @@ // based on install.js by bahmutov

console.log(pkg.name, pkg.version);
console.log("cwd\t\t", process.cwd());
console.log("__dirname\t", __dirname);

@@ -35,2 +33,3 @@ (function avoidSelfInstall() {

var name = "commit-msg";
console.log('installing hook', name);

@@ -53,3 +52,4 @@

// make it executable.
fs.writeFileSync(hook, hookContent);
fs.chmodSync(hook, '755');
fs.symlinkSync(path.resolve("./commit-msg-hook.js"), hook);
// fs.writeFileSync(hook, hookContent);
// fs.chmodSync(hook, '755');
{
"name": "commitplease",
"version": "0.2.0",
"version": "0.3.0",
"description": "Validates strings as commit messages",

@@ -5,0 +5,0 @@ "main": "index.js",

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