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

Upgraded to node-sass 2.0.1 #49

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
/.idea/
102 changes: 56 additions & 46 deletions index.js
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');

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.

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);
})
};


17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"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>"

Choose a reason for hiding this comment

The 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": {
Expand All @@ -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"
}
}