-
Notifications
You must be signed in to change notification settings - Fork 17
Work In Progress: feature: use node-sass's importer hook to help tools track dependencies. #25
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
Open
cgc
wants to merge
1
commit into
davidguttman:master
Choose a base branch
from
cgc:sass-importer
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,8 @@ | |
| "description": "Browserify middleware for adding required styles to the page.", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "test": "browserify -t . -r ./index.js:sassify test/*.js -o test_pack.js && cat test_pack.js | tape-run -b firefox | tap-spec && cat test_pack.js | tape-run -b phantom | tap-spec" | ||
| "test": "browserify -t . -r ./index.js:sassify test/*.js -o test_pack.js && cat test_pack.js | tape-run -b firefox | tap-spec && cat test_pack.js | tape-run -b phantom | tap-spec", | ||
| "test-importer": "node_modules/.bin/mocha test/importer.js" | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't want to make too many assumptions here. Is mocha cool? would you prefer this command be added to the test script? |
||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
|
|
@@ -57,9 +58,11 @@ | |
| }, | ||
| "devDependencies": { | ||
| "browserify": "^9.0.3", | ||
| "mocha": "^2.2.1", | ||
| "tap-spec": "^2.2.2", | ||
| "tape": "^3.5.0", | ||
| "tape-run": "^0.3.0" | ||
| "tape-run": "^0.3.0", | ||
| "watchify": "^2.6.0" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/davidguttman/sassify/issues" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| $bg: red; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| $bg: blue; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| @import './something'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| @import './settings'; | ||
|
|
||
| body { | ||
| background-color: $bg; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| var assert = require("assert"); | ||
| var browserify = require("browserify"); | ||
| var watchify = require("watchify"); | ||
| var fs = require("fs"); | ||
| var path = require("path"); | ||
| var sassify = require(".."); | ||
|
|
||
| function fixturePath(filename) { | ||
| return path.join(__dirname, 'fixtures', filename); | ||
| } | ||
|
|
||
| function copySync(src, dest) { | ||
| fs.writeFileSync(dest, fs.readFileSync(src)); | ||
| } | ||
|
|
||
| var settingsContent = fs.readFileSync(fixturePath('_settings.scss')); | ||
|
|
||
| describe("the sass importer", function() { | ||
| before(function() { | ||
| this.b = browserify(); | ||
| this.b.transform(sassify.configure({ | ||
| 'auto-inject': false | ||
| })) | ||
| .add(fixturePath('main.scss')); | ||
| this.w = watchify(this.b); | ||
| }); | ||
|
|
||
| after(function() { | ||
| fs.writeFileSync(fixturePath('_settings.scss'), settingsContent); | ||
| if (this.w) { | ||
| this.w.close(); | ||
| } | ||
| }); | ||
|
|
||
| it("should update when an imported file changes", function(done) { | ||
| this.w.bundle(function(err, bundle) { | ||
| assert(bundle.toString().match(/background-color:\s*red/)); | ||
|
|
||
| this.w.once('update', function() { | ||
| this.w.bundle(function(err, bundle) { | ||
| assert(bundle.toString().match(/background-color:\s*blue/)); | ||
| done(); | ||
| }.bind(this)); | ||
| }.bind(this)); | ||
|
|
||
| // This will trigger the watcher to update. | ||
| copySync(fixturePath('_settings.scss.new'), fixturePath('_settings.scss')); | ||
| }.bind(this)); | ||
| }); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a bit aggressive to do every possible file, but the alternative is
fs.exists. Not sure which is more/less intrusive?