# css-semver

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

Latest version **0.0.5** (published 2016-11-24) · 0 weekly downloads

## Install

```sh
npm install css-semver
pnpm add css-semver
yarn add css-semver
bun add css-semver
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2016-11-24 |
| First published | 2016-09-06 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | svnv |
| Maintainers | svnv |

## Links

- npm: https://www.npmjs.com/package/css-semver
- Repository: https://github.com/svnv/css-semver
- Homepage: https://github.com/svnv/css-semver#readme
- Issues: https://github.com/svnv/css-semver/issues
- npm.io page: https://npm.io/package/css-semver

## Dependencies (4)

- [css](https://npm.io/package/css.md) ^2.2.1
- [colors](https://npm.io/package/colors.md) ^1.1.2
- [deep-equal](https://npm.io/package/deep-equal.md) ^1.0.1
- [underscore](https://npm.io/package/underscore.md) ^1.8.3

## Recent versions

- 0.0.5 (latest) — 2016-11-24
- 0.0.4 — 2016-11-24
- 0.0.3 — 2016-11-24
- 0.0.2 — 2016-09-06
- 0.0.1 — 2016-09-06

## README

# css-semver [![Build Status](https://travis-ci.org/svnv/css-semver.svg?branch=master)](https://travis-ci.org/svnv/css-semver)

Use this module to compare builds of css files, and get the corresponding [semver](http://semver.org/) 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](https://github.com/svnv/css-semver/blob/master/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

---
_Source: https://npm.io/package/css-semver · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
