https://github.com/lunelson/sass-throw
Testable error/warn/debug functions/mixins for Sass
https://github.com/lunelson/sass-throw
error-handling sass testing
Last synced: 10 months ago
JSON representation
Testable error/warn/debug functions/mixins for Sass
- Host: GitHub
- URL: https://github.com/lunelson/sass-throw
- Owner: lunelson
- License: mit
- Created: 2016-11-02T14:12:11.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-02-01T11:22:32.000Z (over 7 years ago)
- Last Synced: 2025-08-17T03:39:47.391Z (10 months ago)
- Topics: error-handling, sass, testing
- Language: CSS
- Size: 173 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Sass Throw
[](https://travis-ci.org/lunelson/sass-throw)
[](https://www.npmjs.com/package/@lunelson/sass-throw)
[](https://github.com/lunelson/sass-throw/blob/master/LICENSE)
Functions for using Sass' `@error` `@warn` and `@debug` directives in a way that is capturable and testable.
## Installation
```sh
# install in your project
npm i @lunelson/sass-throw
```
## Basic Usage
The basic API consists of the following functions and mixins, which receive a string, and will trigger their corresponding directive (e.g. `@warn`) with the given string when the `$throw-catch` global variable is `false`, but will return the string when `$throw-catch` is true.
```scss
// Sass input file
// NB: you need 'node_modules' in Sass' `importPaths` option
@import '@lunelson/sass-throw/index';
$throw-catch: true;
.test {
error: throw-error('this is an error message via function');
warn: throw-warn('this is a warn message via function');
debug: throw-debug('this is a debug message via function');
}
@include throw-error('this is an error message via mixin');
@include throw-warn('this is a warn message via mixin');
@include throw-debug('this is a debug message via mixin');
```
```css
/* CSS output file */
.test {
error: "this is an error message via function";
warn: "this is a warn message via function";
debug: "this is a debug message via function";
}
.sass-throw .error {
message: "this is an error message via mixin";
}
.sass-throw .warn {
message: "this is a warn message via mixin";
}
.sass-throw .debug {
message: "this is a debug message via mixin";
}
```
Questions? File an issue, or [tweet at me](https://twitter.com/lunelson).