Comparing version 4.0.4 to 4.0.8
129
CHANGELOG.md
@@ -0,1 +1,130 @@ | ||
# v4.0.5 (Mon May 15 2023) | ||
:tada: This release contains work from a new contributor! :tada: | ||
Thank you, Vitali Lovich ([@vlovich](https://github.com/vlovich)), for all your work! | ||
### Release Notes | ||
#### Make sure that errors throw Error instead of string ([#92](https://github.com/domharrington/node-gitlog/pull/92)) | ||
This release fixes how this library throws errors. Instead of throwing `string` it will throw an actual error. Implementations might need updating. | ||
--- | ||
#### 🐛 Bug Fix | ||
- Make sure that errors throw Error instead of string [#92](https://github.com/domharrington/node-gitlog/pull/92) ([@vlovich](https://github.com/vlovich)) | ||
- added tag field [#76](https://github.com/domharrington/node-gitlog/pull/76) ([@jigarzon](https://github.com/jigarzon)) | ||
#### ⚠️ Pushed to `master` | ||
- remove registry ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
- upgrade auto ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
- fix build ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
#### Authors: 3 | ||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
- Juan Ignacio Garzón ([@jigarzon](https://github.com/jigarzon)) | ||
- Vitali Lovich ([@vlovich](https://github.com/vlovich)) | ||
--- | ||
# v4.0.5 (Mon May 15 2023) | ||
:tada: This release contains work from a new contributor! :tada: | ||
Thank you, Vitali Lovich ([@vlovich](https://github.com/vlovich)), for all your work! | ||
### Release Notes | ||
#### Make sure that errors throw Error instead of string ([#92](https://github.com/domharrington/node-gitlog/pull/92)) | ||
This release fixes how this library throws errors. Instead of throwing `string` it will throw an actual error. Implementations might need updating. | ||
--- | ||
#### 🐛 Bug Fix | ||
- Make sure that errors throw Error instead of string [#92](https://github.com/domharrington/node-gitlog/pull/92) ([@vlovich](https://github.com/vlovich)) | ||
- added tag field [#76](https://github.com/domharrington/node-gitlog/pull/76) ([@jigarzon](https://github.com/jigarzon)) | ||
#### ⚠️ Pushed to `master` | ||
- remove registry ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
- upgrade auto ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
- fix build ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
#### Authors: 3 | ||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
- Juan Ignacio Garzón ([@jigarzon](https://github.com/jigarzon)) | ||
- Vitali Lovich ([@vlovich](https://github.com/vlovich)) | ||
--- | ||
# v4.0.5 (Mon May 15 2023) | ||
:tada: This release contains work from a new contributor! :tada: | ||
Thank you, Vitali Lovich ([@vlovich](https://github.com/vlovich)), for all your work! | ||
### Release Notes | ||
#### Make sure that errors throw Error instead of string ([#92](https://github.com/domharrington/node-gitlog/pull/92)) | ||
This release fixes how this library throws errors. Instead of throwing `string` it will throw an actual error. Implementations might need updating. | ||
--- | ||
#### 🐛 Bug Fix | ||
- Make sure that errors throw Error instead of string [#92](https://github.com/domharrington/node-gitlog/pull/92) ([@vlovich](https://github.com/vlovich)) | ||
- added tag field [#76](https://github.com/domharrington/node-gitlog/pull/76) ([@jigarzon](https://github.com/jigarzon)) | ||
#### ⚠️ Pushed to `master` | ||
- upgrade auto ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
- fix build ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
#### Authors: 3 | ||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
- Juan Ignacio Garzón ([@jigarzon](https://github.com/jigarzon)) | ||
- Vitali Lovich ([@vlovich](https://github.com/vlovich)) | ||
--- | ||
# v4.0.5 (Mon May 15 2023) | ||
:tada: This release contains work from a new contributor! :tada: | ||
Thank you, Vitali Lovich ([@vlovich](https://github.com/vlovich)), for all your work! | ||
### Release Notes | ||
#### Make sure that errors throw Error instead of string ([#92](https://github.com/domharrington/node-gitlog/pull/92)) | ||
This release fixes how this library throws errors. Instead of throwing `string` it will throw an actual error. Implementations might need updating. | ||
--- | ||
#### 🐛 Bug Fix | ||
- Make sure that errors throw Error instead of string [#92](https://github.com/domharrington/node-gitlog/pull/92) ([@vlovich](https://github.com/vlovich)) | ||
- added tag field [#76](https://github.com/domharrington/node-gitlog/pull/76) ([@jigarzon](https://github.com/jigarzon)) | ||
#### ⚠️ Pushed to `master` | ||
- fix build ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
#### Authors: 3 | ||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie)) | ||
- Juan Ignacio Garzón ([@jigarzon](https://github.com/jigarzon)) | ||
- Vitali Lovich ([@vlovich](https://github.com/vlovich)) | ||
--- | ||
# v4.0.4 (Tue Jan 05 2021) | ||
@@ -2,0 +131,0 @@ |
@@ -12,6 +12,5 @@ 'use strict'; | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
@@ -23,6 +22,4 @@ if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
@@ -50,3 +47,4 @@ } | ||
body: "%b", | ||
rawBody: "%B" | ||
rawBody: "%B", | ||
tag: "%D" | ||
}; | ||
@@ -64,7 +62,5 @@ var notOptFields = ["status", "files"]; | ||
/** Add optional parameter to command */ | ||
function addOptionalArguments(command, options) { | ||
var commandWithOptions = command; | ||
var cmdOptional = ["author", "since", "after", "until", "before", "committer"]; | ||
for (var i = cmdOptional.length; i--;) { | ||
@@ -75,8 +71,5 @@ if (options[cmdOptional[i]]) { | ||
} | ||
return commandWithOptions; | ||
} | ||
/** Parse the output of "git log" for commit information */ | ||
var parseCommits = function parseCommits(commits, fields, nameStatus) { | ||
@@ -86,20 +79,18 @@ return commits.map(function (rawCommit) { | ||
var commit = parts[0].split(delimiter); | ||
if (parts[1]) { | ||
var parseNameStatus = parts[1].trimLeft().split("\n"); // Removes last empty char if exists | ||
var parseNameStatus = parts[1].trimLeft().split("\n"); | ||
// Removes last empty char if exists | ||
if (parseNameStatus[parseNameStatus.length - 1] === "") { | ||
parseNameStatus.pop(); | ||
} // Split each line into it's own delimited array | ||
} | ||
// Split each line into it's own delimited array | ||
var nameAndStatusDelimited = parseNameStatus.map(function (d) { | ||
return d.split(delimiter); | ||
}); // 0 will always be status, last will be the filename as it is in the commit, | ||
}); | ||
// 0 will always be status, last will be the filename as it is in the commit, | ||
// anything in between could be the old name if renamed or copied | ||
nameAndStatusDelimited.forEach(function (item) { | ||
var status = item[0]; | ||
var tempArr = [status, item[item.length - 1]]; // If any files in between loop through them | ||
var tempArr = [status, item[item.length - 1]]; | ||
// If any files in between loop through them | ||
for (var i = 1, len = item.length - 1; i < len; i++) { | ||
@@ -112,12 +103,9 @@ // If status R then add the old filename as a deleted file + status | ||
} | ||
commit.push.apply(commit, tempArr); | ||
}); | ||
} | ||
debug("commit", commit); // Remove the first empty char from the array | ||
debug("commit", commit); | ||
// Remove the first empty char from the array | ||
commit.shift(); | ||
var parsed = {}; | ||
if (nameStatus) { | ||
@@ -129,3 +117,2 @@ // Create arrays for non optional fields if turned on | ||
} | ||
commit.forEach(function (commitField, index) { | ||
@@ -138,3 +125,2 @@ if (fields[index]) { | ||
var arr = parsed[notOptFields[pos]]; | ||
if (Array.isArray(arr)) { | ||
@@ -149,25 +135,19 @@ arr.push(commitField); | ||
/** Run "git log" and return the result as JSON */ | ||
function createCommandArguments(options) { | ||
// Start constructing command | ||
var command = ["log", "-l0"]; | ||
if (options.findCopiesHarder) { | ||
command.push("--find-copies-harder"); | ||
} | ||
if (options.all) { | ||
command.push("--all"); | ||
} | ||
if (options.includeMergeCommitFiles) { | ||
command.push("-m"); | ||
} | ||
command.push("-n " + options.number); | ||
command = addOptionalArguments(command, options); // Start of custom format | ||
var prettyArgument = "--pretty=@begin@"; // Iterating through the fields and adding them to the custom format | ||
command = addOptionalArguments(command, options); | ||
// Start of custom format | ||
var prettyArgument = "--pretty=@begin@"; | ||
// Iterating through the fields and adding them to the custom format | ||
if (options.fields) { | ||
@@ -178,24 +158,19 @@ options.fields.forEach(function (field) { | ||
} | ||
prettyArgument += delimiter + fieldMap[field]; | ||
}); | ||
} // Close custom format | ||
} | ||
// Close custom format | ||
prettyArgument += "@end@"; | ||
command.push(prettyArgument); // Append branch (revision range) if specified | ||
command.push(prettyArgument); | ||
// Append branch (revision range) if specified | ||
if (options.branch) { | ||
command.push(options.branch); | ||
} // File and file status | ||
} | ||
// File and file status | ||
if (options.nameStatus && !options.fileLineRange) { | ||
command.push("--name-status"); | ||
} | ||
if (options.fileLineRange) { | ||
command.push("-L " + options.fileLineRange.startLine + "," + options.fileLineRange.endLine + ":" + options.fileLineRange.file); | ||
} | ||
if (options.file) { | ||
@@ -205,7 +180,5 @@ command.push("--"); | ||
} | ||
debug("command", options.execOptions, command); | ||
return command; | ||
} | ||
function gitlog(userOptions, cb) { | ||
@@ -215,41 +188,33 @@ if (!userOptions.repo) { | ||
} | ||
if (!fs.existsSync(userOptions.repo)) { | ||
throw new Error("Repo location does not exist"); | ||
} // Set defaults | ||
} | ||
// Set defaults | ||
var options = _extends({}, defaultOptions, userOptions); | ||
var execOptions = _extends({ | ||
cwd: userOptions.repo | ||
}, userOptions.execOptions); | ||
var commandArguments = createCommandArguments(options); | ||
if (!cb) { | ||
var stdout = child_process.execFileSync("git", commandArguments, execOptions).toString(); | ||
var commits = stdout.split("@begin@"); | ||
if (commits[0] === "") { | ||
commits.shift(); | ||
} | ||
debug("commits", commits); | ||
return parseCommits(commits, options.fields, options.nameStatus); | ||
} | ||
child_process.execFile("git", commandArguments, execOptions, function (err, stdout, stderr) { | ||
debug("stdout", stdout); | ||
var commits = stdout.split("@begin@"); | ||
if (commits[0] === "") { | ||
commits.shift(); | ||
} | ||
debug("commits", commits); | ||
cb(stderr || err, parseCommits(commits, options.fields, options.nameStatus)); | ||
if (stderr) { | ||
err = new Error(stderr); | ||
} | ||
cb(err, parseCommits(commits, options.fields, options.nameStatus)); | ||
}); | ||
} | ||
function gitlogPromise(options) { | ||
@@ -256,0 +221,0 @@ return new Promise(function (resolve, reject) { |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("child_process"),r=require("fs");function n(){return(n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var i=((e=require("debug"))&&"object"==typeof e&&"default"in e?e.default:e)("gitlog"),a={hash:"%H",abbrevHash:"%h",treeHash:"%T",abbrevTreeHash:"%t",parentHashes:"%P",abbrevParentHashes:"%P",authorName:"%an",authorEmail:"%ae",authorDate:"%ai",authorDateRel:"%ar",committerName:"%cn",committerEmail:"%ce",committerDate:"%cd",committerDateRel:"%cr",subject:"%s",body:"%b",rawBody:"%B"},s=["status","files"],o={number:10,fields:["abbrevHash","hash","subject","authorName","authorDate"],nameStatus:!0,includeMergeCommitFiles:!1,findCopiesHarder:!1,all:!1},u=function(e,t,r){return e.map((function(e){var n=e.split("@end@"),a=n[0].split("\t");if(n[1]){var o=n[1].trimLeft().split("\n");""===o[o.length-1]&&o.pop(),o.map((function(e){return e.split("\t")})).forEach((function(e){for(var t=e[0],r=[t,e[e.length-1]],n=1,i=e.length-1;n<i;n++)"R"===t.slice(0,1)&&r.push("D",e[n]);a.push.apply(a,r)}))}i("commit",a),a.shift();var u={};return r&&s.forEach((function(e){u[e]=[]})),a.forEach((function(e,n){if(t[n])u[t[n]]=e;else if(r){var a=(n-t.length)%s.length;i("nameStatus",n-t.length,s.length,a,e);var o=u[s[a]];Array.isArray(o)&&o.push(e)}})),u}))};function l(e,l){if(!e.repo)throw new Error("Repo required!");if(!r.existsSync(e.repo))throw new Error("Repo location does not exist");var f=n({},o,e),c=n({cwd:e.repo},e.execOptions),h=function(e){var t=["log","-l0"];e.findCopiesHarder&&t.push("--find-copies-harder"),e.all&&t.push("--all"),e.includeMergeCommitFiles&&t.push("-m"),t.push("-n "+e.number),t=function(e,t){for(var r=e,n=["author","since","after","until","before","committer"],i=n.length;i--;)t[n[i]]&&r.push("--"+n[i]+"="+t[n[i]]);return r}(t,e);var r="--pretty=@begin@";return e.fields&&e.fields.forEach((function(e){if(!a[e]&&!s.includes(e))throw new Error("Unknown field: "+e);r+="\t"+a[e]})),t.push(r+="@end@"),e.branch&&t.push(e.branch),e.nameStatus&&!e.fileLineRange&&t.push("--name-status"),e.fileLineRange&&t.push("-L "+e.fileLineRange.startLine+","+e.fileLineRange.endLine+":"+e.fileLineRange.file),e.file&&(t.push("--"),t.push(e.file)),i("command",e.execOptions,t),t}(f);if(!l){var p=t.execFileSync("git",h,c).toString().split("@begin@");return""===p[0]&&p.shift(),i("commits",p),u(p,f.fields,f.nameStatus)}t.execFile("git",h,c,(function(e,t,r){i("stdout",t);var n=t.split("@begin@");""===n[0]&&n.shift(),i("commits",n),l(r||e,u(n,f.fields,f.nameStatus))}))}exports.default=l,exports.gitlogPromise=function(e){return new Promise((function(t,r){l(e,(function(e,n){e?r(e):t(n)}))}))}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("child_process"),r=require("fs");function n(){return(n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var i=((e=require("debug"))&&"object"==typeof e&&"default"in e?e.default:e)("gitlog"),a={hash:"%H",abbrevHash:"%h",treeHash:"%T",abbrevTreeHash:"%t",parentHashes:"%P",abbrevParentHashes:"%P",authorName:"%an",authorEmail:"%ae",authorDate:"%ai",authorDateRel:"%ar",committerName:"%cn",committerEmail:"%ce",committerDate:"%cd",committerDateRel:"%cr",subject:"%s",body:"%b",rawBody:"%B",tag:"%D"},s=["status","files"],o={number:10,fields:["abbrevHash","hash","subject","authorName","authorDate"],nameStatus:!0,includeMergeCommitFiles:!1,findCopiesHarder:!1,all:!1},u=function(e,t,r){return e.map((function(e){var n=e.split("@end@"),a=n[0].split("\t");if(n[1]){var o=n[1].trimLeft().split("\n");""===o[o.length-1]&&o.pop(),o.map((function(e){return e.split("\t")})).forEach((function(e){for(var t=e[0],r=[t,e[e.length-1]],n=1,i=e.length-1;n<i;n++)"R"===t.slice(0,1)&&r.push("D",e[n]);a.push.apply(a,r)}))}i("commit",a),a.shift();var u={};return r&&s.forEach((function(e){u[e]=[]})),a.forEach((function(e,n){if(t[n])u[t[n]]=e;else if(r){var a=(n-t.length)%s.length;i("nameStatus",n-t.length,s.length,a,e);var o=u[s[a]];Array.isArray(o)&&o.push(e)}})),u}))};function l(e,l){if(!e.repo)throw new Error("Repo required!");if(!r.existsSync(e.repo))throw new Error("Repo location does not exist");var f=n({},o,e),c=n({cwd:e.repo},e.execOptions),h=function(e){var t=["log","-l0"];e.findCopiesHarder&&t.push("--find-copies-harder"),e.all&&t.push("--all"),e.includeMergeCommitFiles&&t.push("-m"),t.push("-n "+e.number),t=function(e,t){for(var r=e,n=["author","since","after","until","before","committer"],i=n.length;i--;)t[n[i]]&&r.push("--"+n[i]+"="+t[n[i]]);return r}(t,e);var r="--pretty=@begin@";return e.fields&&e.fields.forEach((function(e){if(!a[e]&&!s.includes(e))throw new Error("Unknown field: "+e);r+="\t"+a[e]})),t.push(r+="@end@"),e.branch&&t.push(e.branch),e.nameStatus&&!e.fileLineRange&&t.push("--name-status"),e.fileLineRange&&t.push("-L "+e.fileLineRange.startLine+","+e.fileLineRange.endLine+":"+e.fileLineRange.file),e.file&&(t.push("--"),t.push(e.file)),i("command",e.execOptions,t),t}(f);if(!l){var p=t.execFileSync("git",h,c).toString().split("@begin@");return""===p[0]&&p.shift(),i("commits",p),u(p,f.fields,f.nameStatus)}t.execFile("git",h,c,(function(e,t,r){i("stdout",t);var n=t.split("@begin@");""===n[0]&&n.shift(),i("commits",n),r&&(e=new Error(r)),l(e,u(n,f.fields,f.nameStatus))}))}exports.default=l,exports.gitlogPromise=function(e){return new Promise((function(t,r){l(e,(function(e,n){e?r(e):t(n)}))}))}; | ||
//# sourceMappingURL=gitlog.cjs.production.min.js.map |
@@ -6,6 +6,5 @@ import { execFileSync, execFile } from 'child_process'; | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
@@ -17,6 +16,4 @@ if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
@@ -44,3 +41,4 @@ } | ||
body: "%b", | ||
rawBody: "%B" | ||
rawBody: "%B", | ||
tag: "%D" | ||
}; | ||
@@ -58,7 +56,5 @@ var notOptFields = ["status", "files"]; | ||
/** Add optional parameter to command */ | ||
function addOptionalArguments(command, options) { | ||
var commandWithOptions = command; | ||
var cmdOptional = ["author", "since", "after", "until", "before", "committer"]; | ||
for (var i = cmdOptional.length; i--;) { | ||
@@ -69,8 +65,5 @@ if (options[cmdOptional[i]]) { | ||
} | ||
return commandWithOptions; | ||
} | ||
/** Parse the output of "git log" for commit information */ | ||
var parseCommits = function parseCommits(commits, fields, nameStatus) { | ||
@@ -80,20 +73,18 @@ return commits.map(function (rawCommit) { | ||
var commit = parts[0].split(delimiter); | ||
if (parts[1]) { | ||
var parseNameStatus = parts[1].trimLeft().split("\n"); // Removes last empty char if exists | ||
var parseNameStatus = parts[1].trimLeft().split("\n"); | ||
// Removes last empty char if exists | ||
if (parseNameStatus[parseNameStatus.length - 1] === "") { | ||
parseNameStatus.pop(); | ||
} // Split each line into it's own delimited array | ||
} | ||
// Split each line into it's own delimited array | ||
var nameAndStatusDelimited = parseNameStatus.map(function (d) { | ||
return d.split(delimiter); | ||
}); // 0 will always be status, last will be the filename as it is in the commit, | ||
}); | ||
// 0 will always be status, last will be the filename as it is in the commit, | ||
// anything in between could be the old name if renamed or copied | ||
nameAndStatusDelimited.forEach(function (item) { | ||
var status = item[0]; | ||
var tempArr = [status, item[item.length - 1]]; // If any files in between loop through them | ||
var tempArr = [status, item[item.length - 1]]; | ||
// If any files in between loop through them | ||
for (var i = 1, len = item.length - 1; i < len; i++) { | ||
@@ -106,12 +97,9 @@ // If status R then add the old filename as a deleted file + status | ||
} | ||
commit.push.apply(commit, tempArr); | ||
}); | ||
} | ||
debug("commit", commit); // Remove the first empty char from the array | ||
debug("commit", commit); | ||
// Remove the first empty char from the array | ||
commit.shift(); | ||
var parsed = {}; | ||
if (nameStatus) { | ||
@@ -123,3 +111,2 @@ // Create arrays for non optional fields if turned on | ||
} | ||
commit.forEach(function (commitField, index) { | ||
@@ -132,3 +119,2 @@ if (fields[index]) { | ||
var arr = parsed[notOptFields[pos]]; | ||
if (Array.isArray(arr)) { | ||
@@ -143,25 +129,19 @@ arr.push(commitField); | ||
/** Run "git log" and return the result as JSON */ | ||
function createCommandArguments(options) { | ||
// Start constructing command | ||
var command = ["log", "-l0"]; | ||
if (options.findCopiesHarder) { | ||
command.push("--find-copies-harder"); | ||
} | ||
if (options.all) { | ||
command.push("--all"); | ||
} | ||
if (options.includeMergeCommitFiles) { | ||
command.push("-m"); | ||
} | ||
command.push("-n " + options.number); | ||
command = addOptionalArguments(command, options); // Start of custom format | ||
var prettyArgument = "--pretty=@begin@"; // Iterating through the fields and adding them to the custom format | ||
command = addOptionalArguments(command, options); | ||
// Start of custom format | ||
var prettyArgument = "--pretty=@begin@"; | ||
// Iterating through the fields and adding them to the custom format | ||
if (options.fields) { | ||
@@ -172,24 +152,19 @@ options.fields.forEach(function (field) { | ||
} | ||
prettyArgument += delimiter + fieldMap[field]; | ||
}); | ||
} // Close custom format | ||
} | ||
// Close custom format | ||
prettyArgument += "@end@"; | ||
command.push(prettyArgument); // Append branch (revision range) if specified | ||
command.push(prettyArgument); | ||
// Append branch (revision range) if specified | ||
if (options.branch) { | ||
command.push(options.branch); | ||
} // File and file status | ||
} | ||
// File and file status | ||
if (options.nameStatus && !options.fileLineRange) { | ||
command.push("--name-status"); | ||
} | ||
if (options.fileLineRange) { | ||
command.push("-L " + options.fileLineRange.startLine + "," + options.fileLineRange.endLine + ":" + options.fileLineRange.file); | ||
} | ||
if (options.file) { | ||
@@ -199,7 +174,5 @@ command.push("--"); | ||
} | ||
debug("command", options.execOptions, command); | ||
return command; | ||
} | ||
function gitlog(userOptions, cb) { | ||
@@ -209,41 +182,33 @@ if (!userOptions.repo) { | ||
} | ||
if (!existsSync(userOptions.repo)) { | ||
throw new Error("Repo location does not exist"); | ||
} // Set defaults | ||
} | ||
// Set defaults | ||
var options = _extends({}, defaultOptions, userOptions); | ||
var execOptions = _extends({ | ||
cwd: userOptions.repo | ||
}, userOptions.execOptions); | ||
var commandArguments = createCommandArguments(options); | ||
if (!cb) { | ||
var stdout = execFileSync("git", commandArguments, execOptions).toString(); | ||
var commits = stdout.split("@begin@"); | ||
if (commits[0] === "") { | ||
commits.shift(); | ||
} | ||
debug("commits", commits); | ||
return parseCommits(commits, options.fields, options.nameStatus); | ||
} | ||
execFile("git", commandArguments, execOptions, function (err, stdout, stderr) { | ||
debug("stdout", stdout); | ||
var commits = stdout.split("@begin@"); | ||
if (commits[0] === "") { | ||
commits.shift(); | ||
} | ||
debug("commits", commits); | ||
cb(stderr || err, parseCommits(commits, options.fields, options.nameStatus)); | ||
if (stderr) { | ||
err = new Error(stderr); | ||
} | ||
cb(err, parseCommits(commits, options.fields, options.nameStatus)); | ||
}); | ||
} | ||
function gitlogPromise(options) { | ||
@@ -250,0 +215,0 @@ return new Promise(function (resolve, reject) { |
/// <reference types="node" /> | ||
import { ExecFileSyncOptions, ExecException } from "child_process"; | ||
import { ExecFileSyncOptions, ExecFileException } from "child_process"; | ||
declare const fieldMap: { | ||
@@ -21,2 +21,3 @@ readonly hash: "%H"; | ||
readonly rawBody: "%B"; | ||
readonly tag: "%D"; | ||
}; | ||
@@ -37,3 +38,3 @@ export declare type CommitField = keyof typeof fieldMap; | ||
declare const defaultFields: readonly ["abbrevHash", "hash", "subject", "authorName", "authorDate"]; | ||
declare type DefaultField = typeof defaultFields[number]; | ||
declare type DefaultField = (typeof defaultFields)[number]; | ||
export interface GitlogOptions<Fields extends string = DefaultField> { | ||
@@ -102,3 +103,3 @@ /** The location of the repo */ | ||
} | ||
declare type GitlogError = ExecException | string | null; | ||
declare type GitlogError = ExecFileException | null; | ||
declare type CommitBase<Field extends string> = Record<Field, string>; | ||
@@ -105,0 +106,0 @@ declare type CommitBaseWithFiles<Field extends string> = Record<Field | "status", string> & { |
{ | ||
"name": "gitlog", | ||
"version": "4.0.4", | ||
"version": "4.0.8", | ||
"description": "Git log parser for Node.JS", | ||
@@ -15,5 +15,2 @@ "module": "dist/gitlog.esm.js", | ||
}, | ||
"publishConfig": { | ||
"registry": "http://registry.npmjs.org" | ||
}, | ||
"repository": { | ||
@@ -34,8 +31,8 @@ "type": "git", | ||
"devDependencies": { | ||
"@auto-it/all-contributors": "^10.5.0", | ||
"@auto-it/first-time-contributor": "^10.5.0", | ||
"@auto-it/pr-body-labels": "^10.5.0", | ||
"@auto-it/all-contributors": "^10.46.0", | ||
"@auto-it/first-time-contributor": "^10.46.0", | ||
"@auto-it/pr-body-labels": "^10.46.0", | ||
"@types/debug": "^4.1.5", | ||
"@types/jest": "^25.2.1", | ||
"auto": "^10.5.0", | ||
"auto": "^10.46.0", | ||
"husky": "^4.3.6", | ||
@@ -45,7 +42,7 @@ "lint-staged": "^10.5.3", | ||
"tsdx": "^0.13.3", | ||
"typescript": "^3.9.7" | ||
"typescript": "^5.0.4" | ||
}, | ||
"dependencies": { | ||
"debug": "^4.1.1", | ||
"tslib": "^1.14.1" | ||
"tslib": "^2.5.0" | ||
}, | ||
@@ -52,0 +49,0 @@ "husky": { |
@@ -181,2 +181,3 @@ # node-gitlog | ||
- `rawBody` - raw body (subject + body) | ||
- `tag` - raw tag information of commit | ||
@@ -250,2 +251,6 @@ Defaults to 'abbrevHash', 'hash', 'subject' and 'authorName'. | ||
</tr> | ||
<tr> | ||
<td align="center"><a href="https://www.linkedin.com/in/juanignaciogarzon/"><img src="https://avatars.githubusercontent.com/u/9467722?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Juan Ignacio Garzón</b></sub></a><br /><a href="https://github.com/domharrington/node-gitlog/commits?author=jigarzon" title="Documentation">📖</a> <a href="https://github.com/domharrington/node-gitlog/commits?author=jigarzon" title="Code">💻</a></td> | ||
<td align="center"><a href="https://github.com/vlovich"><img src="https://avatars.githubusercontent.com/u/201287?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vitali Lovich</b></sub></a><br /><a href="https://github.com/domharrington/node-gitlog/commits?author=vlovich" title="Tests">⚠️</a> <a href="https://github.com/domharrington/node-gitlog/commits?author=vlovich" title="Code">💻</a></td> | ||
</tr> | ||
</table> | ||
@@ -252,0 +257,0 @@ |
@@ -5,3 +5,3 @@ import { | ||
ExecFileSyncOptions, | ||
ExecException, | ||
ExecFileException, | ||
} from "child_process"; | ||
@@ -32,2 +32,3 @@ import { existsSync } from "fs"; | ||
rawBody: "%B", | ||
tag: "%D", | ||
} as const; | ||
@@ -310,3 +311,3 @@ export type CommitField = keyof typeof fieldMap; | ||
type GitlogError = ExecException | string | null; | ||
type GitlogError = ExecFileException | null; | ||
@@ -385,6 +386,7 @@ type CommitBase<Field extends string> = Record<Field, string>; | ||
cb( | ||
stderr || err, | ||
parseCommits(commits, options.fields, options.nameStatus) | ||
); | ||
if (stderr) { | ||
err = new Error(stderr); | ||
} | ||
cb(err, parseCommits(commits, options.fields, options.nameStatus)); | ||
}); | ||
@@ -391,0 +393,0 @@ } |
@@ -39,2 +39,8 @@ /* eslint-disable handle-callback-err, no-unused-expressions */ | ||
it("throws an error when bad option - promise", async () => { | ||
await expect( | ||
gitlogPromise({ repo: testRepoLocation, branch: "not-a-branch" }) | ||
).rejects.toBeInstanceOf(Error); | ||
}); | ||
it("returns 21 commits from specified branch", (done) => { | ||
@@ -41,0 +47,0 @@ gitlog( |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
131517
1253
262
+ Addedtslib@2.7.0(transitive)
- Removedtslib@1.14.1(transitive)
Updatedtslib@^2.5.0