Detects whether package has been changed since last publish
Great for monorepos. Looks up the commit which was used to publish the last version of the package.
The commit has to be marked with a tag in the format <pkg name>/<pkg version>
. So if the last published package
was 2.0.0
and the package name is foo
, the foo/2.0.0
git tag is looked up.
npm i -S is-pkg-changed
const isPkgChanged = require('is-pkg-changed').default
isPkgChanged('/user/repo/pkg').then(isChanged => console.log(isChanged))
//> true or false or undefined
Arguments:
pkgPath
- string - path to the package.options.ignore
- string[] - an array of filename patterns to ignore when analyzing the working tree for changes since last publish. The default value has:**/test/**
,**/tests/**
and**/*.md
.
Returns:
true
- if there were changes in non-ignored files since last publishfalse
- if there were no changes in non-ignored files since last publishundefined
- if no git tag was found to recognize the publish commit