sass-thematic
sass-thematic copied to clipboard
Relative paths passed as file return undefined
After trying to follow the README, this is what I have
// Sync
const sass = require('sass-thematic');
var ast = sass.parseASTSync({
file: `./test.scss`
});
However, on runtime, I'm getting:
throw new TypeError('Path must be a string. Received ' + inspect(path));
TypeError: Path must be a string. Received undefined
It works if I hardcode the entire file path, but it seems like something is wrong with how the Path is being converted. I'm on Node v6.2.1 and this seems to be a pretty universal problem with a number of different plugins.
I stumbled on the same problem. This one-liner fix is what is needed:
diff --git a/lib/ast.js b/lib/ast.js
index a76c6b5..6594c6b 100644
--- a/lib/ast.js
+++ b/lib/ast.js
@@ -99,7 +99,7 @@ function Importer(opts) {
opts = opts || {};
EventEmitter.call(this);
this.cwd = opts.cwd ? path.resolve(opts.cwd) : process.cwd();
- this.file = opts.file ? path.resolve(opts.cwd, opts.file) : this.cwd;
+ this.file = opts.file ? path.resolve(this.cwd, opts.file) : this.cwd;
this.data = opts.data;
this.includePaths = opts.includePaths || [];