You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3 jaren geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. # Sass Graph
  2. Parses Sass files in a directory and exposes a graph of dependencies
  3. [![Build Status](https://travis-ci.org/xzyfer/sass-graph.svg?branch=master)](https://travis-ci.org/xzyfer/sass-graph)
  4. [![Coverage Status](https://coveralls.io/repos/github/xzyfer/sass-graph/badge.svg?branch=master)](https://coveralls.io/github/xzyfer/sass-graph?branch=master)
  5. [![npm version](https://badge.fury.io/js/sass-graph.svg)](http://badge.fury.io/js/sass-graph)
  6. [![Dependency Status](https://david-dm.org/xzyfer/sass-graph.svg?theme=shields.io)](https://david-dm.org/xzyfer/sass-graph)
  7. [![devDependency Status](https://david-dm.org/xzyfer/sass-graph/dev-status.svg?theme=shields.io)](https://david-dm.org/xzyfer/sass-graph#info=devDependencies)
  8. ## Install
  9. Install with [npm](https://npmjs.org/package/sass-graph)
  10. ```
  11. npm install --save-dev sass-graph
  12. ```
  13. ## Usage
  14. Usage as a Node library:
  15. ```js
  16. var sassGraph = require('./sass-graph');
  17. ```
  18. Usage as a command line tool:
  19. The command line tool will parse a graph and then either display ancestors, descendents or both.
  20. ```
  21. $ ./bin/sassgraph --help
  22. Usage: bin/sassgraph <command> [options] <dir> [file]
  23. Commands:
  24. ancestors Output the ancestors
  25. descendents Output the descendents
  26. Options:
  27. -I, --load-path Add directories to the sass load path
  28. -e, --extensions File extensions to include in the graph
  29. -j, --json Output the index in json
  30. -h, --help Show help
  31. -v, --version Show version number
  32. Examples:
  33. ./bin/sassgraph descendents test/fixtures test/fixtures/a.scss
  34. /path/to/test/fixtures/b.scss
  35. /path/to/test/fixtures/_c.scss
  36. ```
  37. ## API
  38. #### parseDir
  39. Parses a directory and builds a dependency graph of all requested file extensions.
  40. #### parseFile
  41. Parses a file and builds its dependency graph.
  42. ## Options
  43. #### loadPaths
  44. Type: `Array`
  45. Default: `[process.cwd]`
  46. Directories to use when resolved `@import` directives.
  47. #### extensions
  48. Type: `Array`
  49. Default: `['scss', 'css', 'sass']`
  50. File types to be parsed.
  51. #### follow
  52. Type: `Boolean`
  53. Default: `false`
  54. Follow symbolic links.
  55. ## Example
  56. ```js
  57. var sassGraph = require('./sass-graph');
  58. console.log(sassGraph.parseDir('test/fixtures'));
  59. //{ index: {,
  60. // '/path/to/test/fixtures/a.scss': {
  61. // imports: ['b.scss'],
  62. // importedBy: [],
  63. // },
  64. // '/path/to/test/fixtures/b.scss': {
  65. // imports: ['_c.scss'],
  66. // importedBy: ['a.scss'],
  67. // },
  68. // '/path/to/test/fixtures/_c.scss': {
  69. // imports: [],
  70. // importedBy: ['b/scss'],
  71. // },
  72. //}}
  73. ```
  74. ## Running Mocha tests
  75. You can run the tests by executing the following commands:
  76. ```
  77. npm install
  78. npm test
  79. ```
  80. ## Authors
  81. Sass graph was originally written by [Lachlan Donald](http://lachlan.me).
  82. It is now maintained by [Michael Mifsud](http://twitter.com/xzyfer).
  83. ## License
  84. MIT