New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sass-true

Package Overview
Dependencies
Maintainers
3
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sass-true - npm Package Compare versions

Comparing version 7.0.1 to 8.0.0

13

CHANGELOG.md
# True Changelog
## 8.0.0 (02/23/24)
- FEATURE: Add True `sass` option (`string` or Sass implementation instance,
defaults to `'sass'`) to allow using either `sass` or `embedded-sass`.
- FEATURE: Add the
[Node.js package importer](https://sass-lang.com/documentation/js-api/classes/nodepackageimporter/)
to the Sass `importers` option by default, if Dart Sass v1.71 or later is
available. Users can opt out by providing their own `importers` option, e.g.
`{ importers: [] }`.
- BREAKING: Drop support for node < 18
- INTERNAL: Remove `sass` as a peer-dependency.
- INTERNAL: Update dependencies
## 7.0.1 (01/04/24)

@@ -4,0 +17,0 @@

4

lib/index.d.ts
import { CssAtRuleAST, CssCommentAST, CssRuleAST } from '@adobe/css-tools';
import type { Options, StringOptions } from 'sass';
export interface TrueOptions {
describe: (description: string, fn: () => void) => void;
it: (description: string, fn: () => void) => void;
sass?: any;
sourceType?: 'path' | 'string';

@@ -37,4 +37,4 @@ contextLines?: number;

export type Parser = (rule: Rule, ctx: Context) => Parser;
export declare const runSass: (trueOptions: TrueOptions, src: string, sassOptions?: Options<'sync'> | StringOptions<'sync'>) => void;
export declare const runSass: (trueOptions: TrueOptions, src: string, sassOptions?: any) => void;
export declare const formatFailureMessage: (assertion: Assertion) => string;
export declare const parse: (rawCss: Readonly<string>, ctxLines?: Readonly<number>) => Module[];
"use strict";
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
/* eslint-disable no-use-before-define */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {

@@ -27,16 +27,20 @@ if (k2 === undefined) k2 = k;

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.parse = exports.formatFailureMessage = exports.runSass = void 0;
const node_assert_1 = __importDefault(require("node:assert"));
const node_path_1 = __importDefault(require("node:path"));
const css_tools_1 = require("@adobe/css-tools");
const assert = __importStar(require("assert"));
const jest_diff_1 = require("jest-diff");
const lodash_1 = require("lodash");
const path = __importStar(require("path"));
const sass_1 = require("sass");
const constants = __importStar(require("./constants"));
const utils_1 = require("./utils");
const runSass = function (trueOptions, src, sassOptions) {
var _a;
const trueOpts = Object.assign({}, trueOptions);
const sassOpts = Object.assign({}, sassOptions);
const sassPath = path.join(__dirname, '..', 'sass');
// Add True's sass to `loadPaths`
const sassPath = node_path_1.default.join(__dirname, '..', 'sass');
if (sassOpts.loadPaths) {

@@ -48,8 +52,34 @@ sassOpts.loadPaths.push(sassPath);

}
// Warn if arguments match v6 API
// Error if arguments match v6 API
if (typeof src !== 'string' || !trueOptions.describe || !trueOptions.it) {
throw new Error('The arguments provided to `runSass` do not match the new API introduced in True v7. Refer to the v7 release notes for migration documentation: https://github.com/oddbird/true/releases/tag/v7.0.0');
throw new Error('The arguments provided to `runSass` do not match the new API ' +
'introduced in True v7. Refer to the v7 release notes ' +
'for migration documentation: ' +
'https://github.com/oddbird/true/releases/tag/v7.0.0');
}
const compiler = trueOpts.sourceType === 'string' ? sass_1.compileString : sass_1.compile;
const parsedCss = compiler(src, sassOpts).css;
// Error if `style: "compressed"` is used
if (sassOpts.style === 'compressed') {
throw new Error('True requires the default Sass `expanded` output style, ' +
'but `style: "compressed"` was used.');
}
let compiler;
if (trueOpts.sass && typeof trueOpts.sass !== 'string') {
compiler = trueOpts.sass;
}
else {
const sassPkg = (_a = trueOpts.sass) !== null && _a !== void 0 ? _a : 'sass';
try {
// eslint-disable-next-line global-require
compiler = require(sassPkg);
}
catch (err) {
throw new Error(`Cannot find Dart Sass (\`${sassPkg}\`) dependency.`);
}
}
// Add the Sass Node.js package importer, if available
if (!sassOpts.importers && compiler.NodePackageImporter) {
sassOpts.importers = [new compiler.NodePackageImporter()];
}
const compilerFn = trueOpts.sourceType === 'string' ? 'compileString' : 'compile';
const parsedCss = compiler[compilerFn](src, sassOpts).css;
const modules = (0, exports.parse)(parsedCss, trueOpts.contextLines);

@@ -80,3 +110,3 @@ (0, lodash_1.forEach)(modules, (module) => {

if (!assertion.passed) {
assert.fail((0, exports.formatFailureMessage)(assertion));
node_assert_1.default.fail((0, exports.formatFailureMessage)(assertion));
}

@@ -83,0 +113,0 @@ });

{
"name": "sass-true",
"title": "True",
"version": "7.0.1",
"version": "8.0.0",
"description": "Unit testing for Sass.",

@@ -15,4 +15,2 @@ "keywords": [

"homepage": "https://www.oddbird.net/true/",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"license": "BSD-3-Clause",

@@ -44,3 +42,3 @@ "repository": {

"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
"node": ">=18"
},

@@ -68,7 +66,4 @@ "scripts": {

},
"peerDependencies": {
"sass": ">=1.45.0"
},
"dependencies": {
"@adobe/css-tools": "^4.3.2",
"@adobe/css-tools": "^4.3.3",
"jest-diff": "^29.7.0",

@@ -78,10 +73,10 @@ "lodash": "^4.17.21"

"devDependencies": {
"@babel/core": "^7.23.7",
"@babel/preset-env": "^7.23.7",
"@babel/core": "^7.23.9",
"@babel/preset-env": "^7.23.9",
"@babel/preset-typescript": "^7.23.3",
"@types/lodash": "^4.14.202",
"@typescript-eslint/eslint-plugin": "^6.17.0",
"@typescript-eslint/parser": "^6.17.0",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"babel-jest": "^29.7.0",
"chai": "^4.3.10",
"chai": "^4.4.1",
"eslint": "^8.56.0",

@@ -91,16 +86,24 @@ "eslint-config-prettier": "^9.1.0",

"eslint-plugin-import": "^2.29.1",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-simple-import-sort": "^12.0.0",
"jest": "^29.7.0",
"jest-environment-node-single-context": "^29.2.0",
"mocha": "^10.2.0",
"jest-environment-node-single-context": "^29.4.0",
"mocha": "^10.3.0",
"npm-run-all": "^4.1.5",
"postcss": "^8.4.32",
"prettier": "^3.1.1",
"sass": "^1.69.7",
"postcss": "^8.4.35",
"prettier": "^3.2.5",
"sass": "^1.71.1",
"sass-embedded": "^1.71.1",
"sassdoc": "^2.7.4",
"sassdoc-theme-herman": "^5.0.1",
"stylelint": "^16.1.0",
"stylelint": "^16.2.1",
"stylelint-config-standard-scss": "^13.0.0",
"typescript": "^5.3.3"
},
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"exports": {
"types": "./lib/index.d.ts",
"sass": "./_index.scss",
"default": "./lib/index.js"
},
"eyeglass": {

@@ -112,3 +115,3 @@ "needs": "*",

},
"packageManager": "yarn@3.7.0"
"packageManager": "yarn@4.1.0"
}

@@ -38,7 +38,7 @@ # True

```scss
@use 'true' as *;
@use 'pkg:sass-true' as *;
```
Depending on your setup,
you may need to include the full path name:
If you are not using the Sass [Node.js package importer][pkg-importer], you may
need to include the full path name:

@@ -50,2 +50,11 @@ ```scss

Or if you are using the [JavaScript test runner integration][js-runner]:
```scss
@use 'true' as *;
```
[pkg-importer]: https://sass-lang.com/documentation/js-api/classes/nodepackageimporter/
[js-runner]: #using-mocha-jest-or-other-js-test-runners
## One Setting

@@ -151,3 +160,4 @@

2. [Optional] Install `sass` (Dart Sass), if not already installed.
2. [Optional] Install Dart Sass (`sass` or `sass-embedded`), if not already
installed.

@@ -163,3 +173,3 @@ ```bash

```js
const path = require('path');
const path = require('node:path');
const sassTrue = require('sass-true');

@@ -192,3 +202,3 @@

The first argument is an object with required `describe` and `it` options, and
optional `contextLines` and `sourceType` options.
optional `sass`, `contextLines` and `sourceType` options.

@@ -199,2 +209,7 @@ Any JS test runner with equivalents to Mocha's or Jest's `describe` and `it`

The `sass` option is an optional string name of a Dart Sass implementation
installed in the current environment (e.g. `'embedded-sass'` or `'sass'`), or a
Dart Sass implementation instance itself. If none is provided, this defaults to
`'sass'`.
If True can't parse the CSS output, it'll give you some context lines of CSS as

@@ -211,11 +226,19 @@ part of the error message. This context will likely be helpful in understanding

[`compileString`](https://sass-lang.com/documentation/js-api/modules#compileString)
function). By default it is expected to be a path, and `sass.compile` is used --
to pass in a source string (and use `sass.compileString`), add `sourceType: 'string'` to your options passed in as the first argument to `runSass`.
function). By default it is expected to be a path, and `sass.compile` is used.
To pass in a source string (and use `sass.compileString`), add `sourceType:
'string'` to your options passed in as the first argument to `runSass`.
The third (optional) argument to `runSass` accepts the [same
options](https://sass-lang.com/documentation/js-api/interfaces/Options) that
Sass' `compile` or `compileString` expect, and these are passed directly through
to Sass. The only modification `runSass` makes is to add True's sass path to the
`loadPaths` option, so `@use 'true';` works in your Sass test file.
Sass' `compile` or `compileString` expect (e.g. `importers`, `loadPaths`, or
`style`), and these are passed directly through to Sass.
By default, True makes two modifications to these options. First, True's sass
path is added to the `loadPaths` option, so `@use 'true';` works in your Sass
test file. Second, if Dart Sass v1.71 or greater is installed, `importers` is
set to an array containing the [Node.js package importer][pkg-importer], which
supports `pkg:` imports to resolve `@use` and `@import` for external modules
installed via npm or Yarn. If `importers` is set (even as an empty array
`importers: []`), it will override this default importer.
**Note:** True requires the

@@ -228,11 +251,11 @@ [default Sass `'expanded'` output style](https://sass-lang.com/documentation/js-api/modules#OutputStyle),

If you use Webpack's tilde notation, like `@use '~accoutrement/sass/tools'`,
you'll need to tell `runSass` how to handle that. That will require writing a
[custom importer](https://sass-lang.com/documentation/js-api/interfaces/FileImporter)
If you use tilde notation (e.g. `@use '~accoutrement/sass/tools'`) or another
method for importing Sass files from `node_modules`, you'll need to tell
`runSass` how to handle that. That will require writing a [custom
importer](https://sass-lang.com/documentation/js-api/interfaces/FileImporter)
and passing it into the configuration for `runSass`:
```js
const path = require('path');
const { pathToFileURL } = require('url');
const path = require('node:path');
const { pathToFileURL } = require('node:url');
const sassTrue = require('sass-true');

@@ -239,0 +262,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc