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

git-revision-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

git-revision-webpack-plugin - npm Package Compare versions

Comparing version 3.0.4 to 3.0.5

19

lib/index.js

@@ -7,2 +7,3 @@ var buildFile = require('./build-file')

var BRANCH_COMMAND = 'rev-parse --abbrev-ref HEAD'
var LASTCOMMITDATETIME_COMMAND = 'log -1 --format=%cI'

@@ -25,2 +26,5 @@ function GitRevisionPlugin (options) {

this.lastCommitDateTimeCommand = options.lastCommitDateTimeCommand ||
LASTCOMMITDATETIME_COMMAND
if (options.versionCommand && options.lightweightTags) {

@@ -48,2 +52,10 @@ throw new Error('lightweightTags can\'t be used together versionCommand')

buildFile({
compiler: compiler,
gitWorkTree: this.gitWorkTree,
command: this.lastCommitDateTimeCommand,
replacePattern: /\[git-revision-last-commit-datetime\]/gi,
asset: 'LASTCOMMITDATETIME'
})
if (this.createBranchFile) {

@@ -81,2 +93,9 @@ buildFile({

GitRevisionPlugin.prototype.lastcommitdatetime = function () {
return runGitCommand(
this.gitWorkTree,
this.lastCommitDateTimeCommand
)
}
module.exports = GitRevisionPlugin

@@ -105,2 +105,30 @@ /* global describe, it */

})
describe('on setting custom last commit date time command', function () {
it('should run the build on .apply', function () {
var buildFile = sinon.spy()
GitRevisionPlugin.__set__('buildFile', buildFile)
new GitRevisionPlugin({
lastCommitDateTimeCommand: 'custom last commit date time command'
}).apply()
var lastCommitDateTimeCall = buildFile.args.find(function (calls) {
return calls[0].asset === 'LASTCOMMITDATETIME'
})
expect(lastCommitDateTimeCall[0].command).to.eql('custom last commit date time command')
})
it('should run the custom git command on .lastcommitdatetime', function () {
var runGitCommand = sinon.spy()
GitRevisionPlugin.__set__('runGitCommand', runGitCommand)
new GitRevisionPlugin({
lastCommitDateTimeCommand: 'custom last commit date time command'
}).lastcommitdatetime()
expect(runGitCommand.args[0][1]).to.eql('custom last commit date time command')
})
})
})

2

package.json
{
"name": "git-revision-webpack-plugin",
"version": "3.0.4",
"version": "3.0.5",
"description": "Simple webpack plugin that generates VERSION and COMMITHASH files during build",

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

@@ -56,2 +56,3 @@ # Git revision webpack plugin

- `[git-revision-branch]` (only [when branch is enabled](#branch-false))
- `[git-revision-last-commit-datetime]`

@@ -71,3 +72,3 @@ Example:

The `VERSION`, `COMMITHASH` and `BRANCH` are also exposed through a public API.
The `VERSION`, `COMMITHASH`, `LASTCOMMITDATETIME` and `BRANCH` are also exposed through a public API.

@@ -88,2 +89,3 @@ Example using the [DefinePlugin](https://webpack.js.org/plugins/define-plugin/#usage):

'BRANCH': JSON.stringify(gitRevisionPlugin.branch()),
'LASTCOMMITDATETIME': JSON.stringify(gitRevisionPlugin.lastcommitdatetime()),
})

@@ -132,4 +134,6 @@ ]

To change the default `git` command used to read the value of `COMMITHASH`:
To change the default `git` command used to read the value of `COMMITHASH`.
This configuration is not not meant to accept arbitrary user input and it is executed by the plugin without any sanitization.
```javascript

@@ -149,4 +153,6 @@ var GitRevisionPlugin = require('git-revision-webpack-plugin')

To change the default `git` command used to read the value of `VERSION`:
To change the default `git` command used to read the value of `VERSION`.
This configuration is not not meant to accept arbitrary user input and it is executed by the plugin without any sanitization.
```javascript

@@ -166,4 +172,6 @@ var GitRevisionPlugin = require('git-revision-webpack-plugin')

To change the default `git` command used to read the value of `BRANCH`:
To change the default `git` command used to read the value of `BRANCH`.
This configuration is not not meant to accept arbitrary user input and it is executed by the plugin without any sanitization.
```javascript

@@ -181,2 +189,20 @@ var GitRevisionPlugin = require('git-revision-webpack-plugin')

### `lastCommitDateTimeCommand: 'log -1 --format=%cI'`
To change the default `git` command used to read the value of `LASTCOMMITDATETIME`.
This configuration is not not meant to accept arbitrary user input and it is executed by the plugin without any sanitization.
```javascript
var GitRevisionPlugin = require('git-revision-webpack-plugin')
module.exports = {
plugins: [
new GitRevisionPlugin({
branchCommand: 'log -1 --format=%ci'
})
]
}
```
## Outdated webpack

@@ -183,0 +209,0 @@

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