Socket
Socket
Sign inDemoInstall

css-semver

Package Overview
Dependencies
34
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    css-semver

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


Version published
Maintainers
1
Install size
2.22 MB
Created

Readme

Source

css-semver Build Status

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

FAQs

Last updated on 24 Nov 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc