-
Notifications
You must be signed in to change notification settings - Fork 96
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
Upgraded to node-sass 2.0.1 #49
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
/.idea/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,62 @@ | ||
var path = require('path') | ||
var mkdirp = require('mkdirp') | ||
var includePathSearcher = require('include-path-searcher') | ||
var CachingWriter = require('broccoli-caching-writer') | ||
var sass = require('node-sass') | ||
var _ = require('lodash') | ||
var Promise = require('rsvp').Promise | ||
|
||
module.exports = SassCompiler | ||
SassCompiler.prototype = Object.create(CachingWriter.prototype) | ||
SassCompiler.prototype.constructor = SassCompiler | ||
function SassCompiler (inputTrees, inputFile, outputFile, options) { | ||
if (!(this instanceof SassCompiler)) return new SassCompiler(inputTrees, inputFile, outputFile, options) | ||
if (!Array.isArray(inputTrees)) throw new Error('Expected array for first argument - did you mean [tree] instead of tree?') | ||
|
||
CachingWriter.call(this, inputTrees, options) | ||
|
||
this.inputFile = inputFile | ||
this.outputFile = outputFile | ||
options = options || {} | ||
this.sassOptions = { | ||
imagePath: options.imagePath, | ||
outputStyle: options.outputStyle, | ||
sourceComments: options.sourceComments, | ||
sourceMap: options.sourceMap, | ||
precision: options.precision | ||
} | ||
} | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var mkdirp = require('mkdirp'); | ||
var includePathSearcher = require('include-path-searcher'); | ||
var CachingWriter = require('broccoli-caching-writer'); | ||
var sass = require('node-sass'); | ||
var _ = require('lodash'); | ||
var Promise = require('rsvp').Promise; | ||
|
||
module.exports = SassCompiler; | ||
SassCompiler.prototype = Object.create(CachingWriter.prototype); | ||
SassCompiler.prototype.constructor = SassCompiler; | ||
function SassCompiler(inputTrees, inputFile, outputFile, options) { | ||
if (!(this instanceof SassCompiler)) | ||
return new SassCompiler(inputTrees, inputFile, outputFile, options); | ||
|
||
SassCompiler.prototype.updateCache = function(includePaths, destDir) { | ||
var self = this | ||
if (!Array.isArray(inputTrees)) | ||
throw new Error('Expected array for first argument - did you mean [tree] instead of tree?'); | ||
|
||
return new Promise(function(resolve, reject) { | ||
var destFile = path.join(destDir, self.outputFile) | ||
mkdirp.sync(path.dirname(destFile)) | ||
CachingWriter.call(this, inputTrees, options); | ||
|
||
var sassOptions = { | ||
file: includePathSearcher.findFileSync(self.inputFile, includePaths), | ||
includePaths: includePaths, | ||
outFile: destFile, | ||
success: function() { | ||
resolve(this) | ||
}, | ||
error: function(err) { | ||
reject(err) | ||
} | ||
this.inputFile = inputFile; | ||
this.outputFile = outputFile; | ||
options = options || {}; | ||
this.sassOptions = { | ||
imagePath: options.imagePath, | ||
outputStyle: options.outputStyle, | ||
sourceComments: options.sourceComments, | ||
sourceMap: options.sourceMap, | ||
precision: options.precision | ||
} | ||
_.merge(sassOptions, self.sassOptions) | ||
sass.renderFile(sassOptions) | ||
}) | ||
} | ||
|
||
SassCompiler.prototype.updateCache = function (includePaths, destDir) { | ||
var self = this | ||
|
||
return new Promise(function (resolve, reject) { | ||
var destFile = path.join(destDir, self.outputFile); | ||
mkdirp.sync(path.dirname(destFile)); | ||
|
||
var sassOptions = { | ||
file: includePathSearcher.findFileSync(self.inputFile, includePaths), | ||
includePaths: includePaths, | ||
outFile: destFile, | ||
success: function (res) { | ||
fs.writeFile(destFile, res.css, function (err) { | ||
if (err != null) | ||
reject(err); | ||
else | ||
resolve(this); | ||
}); | ||
}, | ||
error: function (err) { | ||
reject(err) | ||
} | ||
}; | ||
_.merge(sassOptions, self.sassOptions); | ||
sass.render(sassOptions); | ||
}) | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
{ | ||
"name": "broccoli-sass", | ||
"description": "Libsass-based Sass compiler for Broccoli", | ||
"version": "0.3.3", | ||
"author": "Jo Liss <joliss42@gmail.com>", | ||
"version": "0.3.4", | ||
"author": [ | ||
"Jo Liss <joliss42@gmail.com>", | ||
"Jaroslaw Zabiello <hipertracker@gmail.com>" | ||
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. I am unsure if you are considered the original author, rather just contributor. If you end up committing actively long-term I am sure @joliss would share this responsibility and authorship with you |
||
], | ||
"main": "index.js", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/joliss/broccoli-sass" | ||
"url": "https://github.com/hipertracker/broccoli-sass" | ||
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. this is wrong |
||
}, | ||
"keywords": [ | ||
"broccoli-plugin", | ||
|
@@ -17,11 +20,11 @@ | |
"libsass" | ||
], | ||
"dependencies": { | ||
"broccoli-caching-writer": "^0.5.0", | ||
"broccoli-caching-writer": "^0.5.5", | ||
"include-path-searcher": "^0.1.0", | ||
"lodash": "~2.4.1", | ||
"mkdirp": "^0.3.5", | ||
"node-sass": "^1.1.4", | ||
"rsvp": "^3.0.6" | ||
"lodash": "^3.3.0", | ||
"mkdirp": "^0.5.0", | ||
"node-sass": "^2.0.1", | ||
"rsvp": "^3.0.17" | ||
} | ||
} |
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.
although this is pre-existing, we should require the exact part of lodash that we need. Otherwise this can be a spin up hit.