Git Product home page Git Product logo

Comments (3)

jonycheung avatar jonycheung commented on August 18, 2024

@serjp which version of less-watch-compiler Could you try the latest?

from deadsimple-less-watch-compiler.

serbut avatar serbut commented on August 18, 2024

@jonycheung [email protected], the latest in npm. Tried version 1.6.13 - seems to be ok.

from deadsimple-less-watch-compiler.

mickeyvip avatar mickeyvip commented on August 18, 2024

I am experiencing the same problem with every version > 1.4 (1.4.2 works ok).

Just set the watchFolder to be relative:

./less
../src/less (in my case)

and the exception is thrown.

Debugging the code of the latest version (1.10) I encountered the following code in lessWatchCompilerUtils.js:184:

fileWatcher: function fileWatcher(f, files, options, filelist, fileimportlist, watchCallback) {
  if (filelist.indexOf(f) !== -1) return;
  filelist[filelist.length] = f;

  if (f.indexOf('.') !== -1) {
    fileimportlist[f] = fileSearch.findLessImportsInFile(f);
  }
  lessWatchCompilerUtilsModule.setupWatcher(f, files, options, watchCallback);
  for (var i in fileimportlist[f]) {
    if (filelist.indexOf(fileimportlist[f][i]) === -1) {
      lessWatchCompilerUtilsModule.setupWatcher(path.normalize(path.dirname(f) + '/' + fileimportlist[f][i]), files, options, watchCallback);
    }
  }
}

this function is called (probably the first time) with f set to the watchFolder and the second if (if (f.indexOf('.') !== -1)) will resolve to true if f has . inside it (and every relative folder name does) calling fileSearch.findLessImportsInFile(f) which will fail by calling fs.readFileSync(f, 'utf8') in filesearch.js:15.

The condition if (f.indexOf('.') !== -1) if pretty fragile one. Why not checking if f is a directory?

Changing the condition to if (f.lastIndexOf('.') > 2) solves the problem for me, but it's a hack.

Thank you.

from deadsimple-less-watch-compiler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.