Socket
Socket
Sign inDemoInstall

sass-graph

Package Overview
Dependencies
31
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    sass-graph

Parse sass files and extract a graph of imports


Version published
Weekly downloads
1.8M
increased by5.57%
Maintainers
2
Install size
2.38 MB
Created
Weekly downloads
 

Package description

What is sass-graph?

The sass-graph npm package is a utility that helps in analyzing the dependencies of Sass files in a project. It parses Sass files to find all the `@import` statements and constructs a graph of the relationships between files. This is particularly useful for understanding and managing complex stylesheets structures in large projects.

What are sass-graph's main functionalities?

Parsing a directory of Sass files

This feature allows you to parse an entire directory of Sass files to create a graph representing the dependencies between them.

const sassGraph = require('sass-graph');
const graph = sassGraph.parseDir('path/to/sass/files');

Finding dependencies of a single Sass file

This feature is used to find all the files that depend on a single Sass file, which can be useful for understanding the impact of changes to that file.

const sassGraph = require('sass-graph');
const graph = sassGraph.parseFile('path/to/sass/file.scss', options);
const dependencies = graph.index['path/to/sass/file.scss'].importedBy;

Watching a directory of Sass files for changes

This feature sets up a watcher on a directory of Sass files and triggers a callback with the changed files when a change is detected.

const sassGraph = require('sass-graph');
const graph = sassGraph.parseDir('path/to/sass/files');
sassGraph.watch('path/to/sass/files', options, (changedFiles) => {
  console.log('Files changed:', changedFiles);
});

Other packages similar to sass-graph

Readme

Source

Sass Graph

Parses Sass files in a directory and exposes a graph of dependencies

Build Status Coverage Status npm version Dependency Status devDependency Status

Install

Install with npm

npm install --save-dev sass-graph

Usage

Usage as a Node library:

var sassGraph = require('./sass-graph');

Usage as a command line tool:

The command line tool will parse a graph and then either display ancestors, descendents or both.

$ ./bin/sassgraph --help
Usage: bin/sassgraph <command> [options] <dir> [file]

Commands:
  ancestors    Output the ancestors
  descendents  Output the descendents

Options:
  -I, --load-path   Add directories to the sass load path
  -e, --extensions  File extensions to include in the graph
  -j, --json        Output the index in json
  -h, --help        Show help
  -v, --version     Show version number

Examples:
  ./bin/sassgraph descendents test/fixtures test/fixtures/a.scss
  /path/to/test/fixtures/b.scss
  /path/to/test/fixtures/_c.scss

API

parseDir

Parses a directory and builds a dependency graph of all requested file extensions.

parseFile

Parses a file and builds its dependency graph.

Options

loadPaths

Type: Array Default: [process.cwd]

Directories to use when resolved @import directives.

extensions

Type: Array Default: ['scss', 'sass']

File types to be parsed.

follow

Type: Boolean Default: false

Follow symbolic links.

exclude

Type: RegExp Default: undefined

Exclude files matching regular expression.

Example

var sassGraph = require('./sass-graph');
console.log(sassGraph.parseDir('test/fixtures'));

//{ index: {,
//    '/path/to/test/fixtures/a.scss': {
//        imports: ['b.scss'],
//        importedBy: [],
//    },
//    '/path/to/test/fixtures/b.scss': {
//        imports: ['_c.scss'],
//        importedBy: ['a.scss'],
//    },
//    '/path/to/test/fixtures/_c.scss': {
//        imports: [],
//        importedBy: ['b/scss'],
//    },
//}}

Running Mocha tests

You can run the tests by executing the following commands:

npm install
npm test

Authors

Sass graph was originally written by Lachlan Donald. It is now maintained by Michael Mifsud.

License

MIT

Keywords

FAQs

Last updated on 01 Sep 2022

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