Skip to content

Commit

Permalink
Merge pull request pmowrer#13 from lencioni/sass-null
Browse files Browse the repository at this point in the history
Return `sass.NULL` when not handling the file
  • Loading branch information
pmowrer committed Dec 1, 2015
2 parents 241aeb1 + 600140c commit dce4b7d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
},
"dependencies": {
"is-there": "^4.0.0",
"lodash": "^3.10.1"
"lodash": "^3.10.1",
"node-sass": "^3.0.0"
},
"devDependencies": {
"babel": "^5.8.23",
Expand Down
41 changes: 20 additions & 21 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
import _ from 'lodash';
import {resolve} from 'path';
import isThere from 'is-there';
import sass from 'node-sass';

export default function(url, prev) {
if (/\.json$/.test(url)) {
let includePaths = this.options.includePaths ? this.options.includePaths.split(':') : [];
let paths = []
.concat(prev.slice(0, prev.lastIndexOf('/')))
.concat(includePaths);

let files = paths
.map(path => resolve(path, url))
.filter(isThere);

if (files.length === 0) {
return new Error(`Unable to find "${url}" from the following path(s): ${paths.join(', ')}. Check includePaths.`);
}

return {
contents: parseJSON(require(files[0]))
};
} else {
return {
file: url
};
if (!/\.json$/.test(url)) {
return sass.NULL;
}

let includePaths = this.options.includePaths ? this.options.includePaths.split(':') : [];
let paths = []
.concat(prev.slice(0, prev.lastIndexOf('/')))
.concat(includePaths);

let files = paths
.map(path => resolve(path, url))
.filter(isThere);

if (files.length === 0) {
return new Error(`Unable to find "${url}" from the following path(s): ${paths.join(', ')}. Check includePaths.`);
}

return {
contents: parseJSON(require(files[0]))
};
}

function parseJSON(json) {
Expand Down

0 comments on commit dce4b7d

Please sign in to comment.