Use this module to compare builds of css files, and get the corresponding semver upgrade increment based on changes in the stylesheets.
cssSemver(oldCss, newCss, options)
Arguments:
oldCss
stringnewCss
stringoptions
object, can be used to activate verbose mode
The exported function returns:
null
when there is no change in the styles"major"
when the old build contains selecors not present in the new build. The api has changed and things depending of the old css structure might break."minor"
when new selectors are added to the new build. A new feature has been added to the api."patch"
when the selectors are equal but there are other changes to the stylesheet. A bug has been fixed but the api is unchanged.
var cssSemver = require('css-semver')
cssSemver('.old { color: #fff }', '.changed { color: #fff }');
// returns "major"
Verbose mode will log a diff of the changes in the build to the console.
var cssSemver = require('css-semver')
cssSemver('.old { color: #fff }', '.added { color: #fff }', {verbose: true});
// - .old
// + .added
// returns "major"
See tests.js for the test suite.
To run the test suite use this command.
npm test
- Check if order of selectors is the same, and log changes
- Do a deep comparison on each rule and log changed rules