Skip to content

Commit

Permalink
Merge pull request #74 from ludwiktrammer/master
Browse files Browse the repository at this point in the history
Add an option to follow symbolic links
  • Loading branch information
xzyfer authored Apr 27, 2017
2 parents 76bf364 + 9e64392 commit 2869c65
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions bin/sassgraph
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ var yargs = require('yargs')
type: 'array',
})

.option('f', {
alias: 'follow',
default: false,
describe: 'Follow symbolic links',
type: 'bool',
})

.option('j', {
alias: 'json',
default: false,
Expand Down Expand Up @@ -85,6 +92,7 @@ try {
var graph = require('../').parseDir(directory, {
extensions: argv.extensions,
loadPaths: loadPaths,
follow: argv.follow,
});

if(argv.json) {
Expand Down
7 changes: 7 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ Default: `['scss', 'css', 'sass']`

File types to be parsed.

#### follow

Type: `Boolean`
Default: `false`

Follow symbolic links.

## Example

```js
Expand Down
3 changes: 2 additions & 1 deletion sass-graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ function Graph(options, dir) {
this.dir = dir;
this.extensions = options.extensions || [];
this.index = {};
this.follow = options.follow || false;
this.loadPaths = _(options.loadPaths).map(function(p) {
return path.resolve(p);
}).value();

if (dir) {
var graph = this;
_.each(glob.sync(dir+'/**/*.@('+this.extensions.join('|')+')', { dot: true, nodir: true }), function(file) {
_.each(glob.sync(dir+'/**/*.@('+this.extensions.join('|')+')', { dot: true, nodir: true, follow: this.follow }), function(file) {
graph.addFile(path.resolve(file));
});
}
Expand Down

0 comments on commit 2869c65

Please sign in to comment.