Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash on node 0.12 #36

Closed
hansmbakker opened this issue Feb 9, 2015 · 5 comments
Closed

crash on node 0.12 #36

hansmbakker opened this issue Feb 9, 2015 · 5 comments
Assignees
Labels

Comments

@hansmbakker
Copy link

using node-compass 0.2.3

On index.js@line 233 there is a loop over the properties of a files object.

However, on node 0.12 this files object is just an array - you can do a forEach here.

The code expecting an object crashes here:

/somepath/node_modules/node-compass/index.js:237
            if (last(file.split('.')) === 'css') {
                          ^
TypeError: undefined is not a function
    at /somepath/node_modules/node-compass/index.js:237:27
    at FSReqWrap.oncomplete (fs.js:99:15)
@hansmbakker
Copy link
Author

solution:
line 67:

files.forEach (function(file) {
        var parts = file.split('.');

        if (['scss', 'sass'].indexOf(last(parts)) === -1) return;

        var name = last(parts[0].split('/'));
        var fullPath = path.join(path.join(opts.project, opts.sass), file);
        var cssPath = path.join(path.join(opts.project, opts.css), name) + '.css';

        if (!cache[cssPath]) return;

        need++;

        fs.stat(fullPath, getSassFunction(fullPath, cssPath, doneFunction));
      });

line 232:

files.forEach(function(file) {
            if (last(file.split('.')) === 'css') {
              need++;
              var full = path.join(path.join(opts.project, opts.sass), file);

              fs.readFile(full, getCSSFunction(full, doneFunction));
            }
          });

@nathggns
Copy link
Owner

nathggns commented Feb 9, 2015

While this is in a current rewrite, I think I'll write a patch for the current version to fix this now.

@nathggns nathggns self-assigned this Feb 9, 2015
@nathggns nathggns added the bug label Feb 9, 2015
@nathggns
Copy link
Owner

nathggns commented Feb 9, 2015

This has nothing to do with the node version I think.

I think the middleware can't find your compass project files.

Right now it just assumes they're there. I'll work on fixing that.

@nathggns
Copy link
Owner

nathggns commented Feb 9, 2015

Try now. This is fixed in node-compass@0.2.4 I believe it was actually failing because you've misconfigured it but it'll tell you that if it is. Regardless, I've incorporated your "fix" because its just nicer code.

@hansmbakker
Copy link
Author

I did console.log(files) and it contained an array ['style.scss', 'style.css'] instead of the files object that version 0.2.3 expected.

I haven't changed any configuration about fs.readDir and as documented here http://nodejs.org/api/fs.html#fs_fs_readdir_path_callback, fs.readDir returns an array of filenames on v0.12.0.

Thank you for fixing it, though :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants