Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @lunelson/sass-throw with all npm packages installed. Try it out:

var sassThrow = require("@lunelson/sass-throw")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@lunelson/sass-throw v2.1.0

Testable Sass error/warn/debug directives via proxy functions and mixins

Sass Throw

Functions for using Sass' @error @warn and @debug directives in a way that is capturable and testable.

Installation

# 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.

// 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 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.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free