michaelwayman / node-sass-chokidar

A thin wrapper around node-sass to replicate the --watch using chokidar instead of Gaze
MIT License
291 stars 37 forks source link

Emacs lock files still cause problems #74

Open jdunnpenguin opened 6 years ago

jdunnpenguin commented 6 years ago

I've seen both #40 and #24 and while editing scss files with emacs I'm using the match regex option to exclude emacs lockfiles: node-sass-chokidar src/ -o src/ --watch --recursive --match-regex '^[^#]*$'

Since the lock files include '#' characters and my file names do not this should work and it does until I save the file. Then:

fs.js:113
    throw err;
    ^

Error: ENOENT: no such file or directory, stat '/home/jdunn/src/reactjs-ui/src/.#global.scss'
    at Object.statSync (fs.js:815:3)
    at Graph.addFile (/home/jdunn/src/reactjs-ui/node_modules/sass-graph/sass-graph.js:64:18)
    at /home/jdunn/src/reactjs-ui/node_modules/sass-graph/sass-graph.js:54:13
    at arrayEach (/home/jdunn/src/reactjs-ui/node_modules/lodash/lodash.js:516:11)
    at Function.forEach (/home/jdunn/src/reactjs-ui/node_modules/lodash/lodash.js:9342:14)
    at new Graph (/home/jdunn/src/reactjs-ui/node_modules/sass-graph/sass-graph.js:53:7)
    at Object.module.exports.parseDir (/home/jdunn/src/reactjs-ui/node_modules/sass-graph/sass-graph.js:156:17)
    at buildGraph (/home/jdunn/src/reactjs-ui/node_modules/node-sass-chokidar/bin/node-sass-chokidar:257:23)
    at FSWatcher.changeHandler (/home/jdunn/src/reactjs-ui/node_modules/node-sass-chokidar/bin/node-sass-chokidar:294:13)
    at FSWatcher.emit (events.js:182:13)

Tracing through the code the issue is that the regex filter is not applied in sass-graph.js when the Graph object is instantiated. Creating the Graph triggers a scan of the directory where the .#global.scss file is found and then a stat call throws the ENOENT exception.

Versions grepped out of npm ls: (env) [jdunn@localhost reactjs-ui]$ npm ls | grep sass 2>/dev/null ├─┬ node-sass-chokidar@1.3.3 │ ├─┬ node-sass@4.9.3 │ │ ├── sass-graph@2.2.4 deduped │ ├─┬ sass-graph@2.2.4

I'll turn off emacs lock files for now, but that's not a great long term solution.