Skip to content

A module to diff changes to a css file and get the semver version increment type.

License

Notifications You must be signed in to change notification settings

svnv/css-semver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

css-semver

Build Status Greenkeeper badge

Use this module to compare builds of css files, and get the corresponding semver upgrade increment based on changes in the stylesheets.

How to use

cssSemver(oldCss, newCss, options)

Arguments:

  • oldCss string
  • newCss string
  • options 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.

Example

var cssSemver = require('css-semver')
cssSemver('.old { color: #fff }', '.changed { color: #fff }');
// returns "major"

Example with verbose mode

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"

Tests

See tests.js for the test suite.

To run the test suite use this command.

npm test

TODO

Better verbose mode logging for patch

  • Check if order of selectors is the same, and log changes
  • Do a deep comparison on each rule and log changed rules

About

A module to diff changes to a css file and get the semver version increment type.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published