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

Fix --watch option for directories #512

Merged
merged 1 commit into from
Nov 5, 2014
Merged

Fix --watch option for directories #512

merged 1 commit into from
Nov 5, 2014

Conversation

kevva
Copy link
Member

@kevva kevva commented Nov 5, 2014

Switches out node-watch for gaze since it's used more widely.

Fixes #250 and #312.

Switches out `node-watch` for `gaze` since it's used more widely

Fixes #250 and #312.
@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 58f69a6 on kevva:watch into a4be152 on sass:master.

andrew added a commit that referenced this pull request Nov 5, 2014
Fix `--watch` option for directories
@andrew andrew merged commit bb91cfe into sass:master Nov 5, 2014
@andrew
Copy link
Contributor

andrew commented Nov 5, 2014

Nice work @kevva!

@kevva
Copy link
Member Author

kevva commented Nov 5, 2014

Thanks. Guess we can ignore the 0.11 issues for now. There's an open issue about it on shama/gaze#145 and probably a fix in shama/gaze#151.

@jareware
Copy link

jareware commented Nov 5, 2014

Wow, thanks for a quick fix! Not working for me yet, though:

$ npm install git+https://github.com/sass/node-sass.git#491f5fc8075a1192cc2659e3525356d198f64430
$ ./node_modules/.bin/node-sass --watch src/index.scss 
Provide a Sass file to render

  Example
    node-sass --output-style compressed foobar.scss foobar.css
    cat foobar.scss | node-sass --output-style compressed > foobar.css

Same if I try with a dir as the argument. Ideas..?

@kevva
Copy link
Member Author

kevva commented Nov 5, 2014

@jareware, node-sass src/index.scss --watch should work. It'll automatically add the src file.

@jareware
Copy link

jareware commented Nov 5, 2014

And sure enough, it does, thanks! :)

Still doesn't seem to watch recursively, though..?

@kevva
Copy link
Member Author

kevva commented Nov 5, 2014

You need to add the folder, node-sass src/index.scss --watch src. It won't watch recursively though. @andrew, @am11, should it? Easy to add.

@am11
Copy link
Contributor

am11 commented Nov 5, 2014

Perhaps with --watch --recursive it should do that. Without --recursive, it shouldn't.

@kevva
Copy link
Member Author

kevva commented Nov 5, 2014

Okey, will PR.

@peterjmag
Copy link
Contributor

Thanks for your work on this @kevva. However, after playing around with it a bit in 1.2.1, I'm not sure the new behavior makes sense. For instance:

peterjmag@peters-imac ~/git/node-sass-playground (git::master)
$ node-sass styles/scss/main.scss --watch styles/scss/
=> changed: /Users/peterjmag/git/node-sass-playground/styles/scss/test.scss
Rendering Complete, saving .css file...
Wrote CSS to /Users/peterjmag/git/node-sass-playground/main.css
=> changed: /Users/peterjmag/git/node-sass-playground/styles/scss/another.scss
Rendering Complete, saving .css file...
Wrote CSS to /Users/peterjmag/git/node-sass-playground/main.css

Note that changes in test.scss and another.scss merely trigger recompilation of the (unchanged) main.scss, and they don't recompile the actual changed files. Here's the kind of behavior I would expect (using Ruby sass 3.4.7):

peterjmag@peters-imac ~/git/node-sass-playground (git::master)
$ sass --watch --sourcemap=none styles/scss/:styles/css/
>>> Sass is watching for changes. Press Ctrl-C to stop.
      write styles/css/another.css
      write styles/css/main.css
      write styles/css/test.css
>>> Change detected to: styles/scss/test.scss
      write styles/css/test.css
>>> Change detected to: styles/scss/another.scss
      write styles/css/another.css

Ruby sass also watches for changes in @imported dependencies, even if you're only watching one file:

peterjmag@peters-imac ~/git/node-sass-playground (git::master)
$ sass --watch --sourcemap=none styles/scss/main.scss:styles/css/main.css
>>> Sass is watching for changes. Press Ctrl-C to stop.
    write styles/css/main.css
>>> Change detected to: styles/scss/_partial.scss
    write styles/css/main.css

Am I wrong in thinking that node-sass's watch behavior should more or less match that of Ruby sass?

For reference, here are a couple of my previous comments on the topic:
#312 (comment)
#250 (comment)

@kevva
Copy link
Member Author

kevva commented Nov 6, 2014

Oh, that's because it only renders the file defined in src. We need to set a new src everytime a file change. Will fix.

Not sure how we'd watch for imported files though.

@kevva
Copy link
Member Author

kevva commented Nov 6, 2014

@peterjmag #520.

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

Successfully merging this pull request may close these issues.

node-sass --watch doesn't work for directories
6 participants