Skip to content

Commit

Permalink
Merge pull request #136 from jasonsanjose/jasonsanjose/node-sass-3.2.0
Browse files Browse the repository at this point in the history
Update node-sass to 3.2.0
  • Loading branch information
jasonsanjose committed Jul 9, 2015
2 parents 62b1676 + d9638fc commit 618d6b2
Show file tree
Hide file tree
Showing 3,213 changed files with 110,940 additions and 97,295 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
112 changes: 71 additions & 41 deletions Compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*jslint nomen:true, vars:true, regexp:true*/
/*jslint nomen:true, vars:true, regexp:true, plusplus:true*/
/*global window, console, define, brackets, $, PathUtils*/

define(function (require, exports, module) {
Expand All @@ -38,8 +38,8 @@ define(function (require, exports, module) {
ProjectManager = brackets.getModule("project/ProjectManager");

// Boilerplate to load NodeDomain
var _domainPath = ExtensionUtils.getModulePath(module, "node/3.0.0/SASSDomain"),
_nodeDomain = new NodeDomain("sass-v3.0.0", _domainPath);
var _domainPath = ExtensionUtils.getModulePath(module, "node/2.0.2/SASSDomain"),
_nodeDomain = new NodeDomain("sass-v2.0.2", _domainPath);

// Initialize temp folder on windows only
// This is to normalize windows paths instead of using Node's os.tmpdir()
Expand All @@ -63,46 +63,75 @@ define(function (require, exports, module) {
scannedFileMap = {},
partialErrorMap = {};

function _fixSourceMap(json, prefs) {
// Normalize a path (e.g. a/b/../c becomes a/c)
function _normalizePath(path) {
var up = 0,
i,
parts = path.split("/").filter(function (part, index) {
return !!part;
});

for (i = parts.length - 1; i >= 0; i--) {
var last = parts[i];
if (last === ".") {
parts.splice(i, 1);
} else if (last === "..") {
parts.splice(i, 1);
up++;
} else if (up) {
parts.splice(i, 1);
up--;
}
}
while (up--) {
parts.unshift("..");
}

return parts.join("/");
}

function _fixSourceMapPaths(json, css, prefs) {
var inputFile = prefs.inputFile,
cssFilePath = prefs.outputCSSFile.fullPath,
sourceMapFilePath = prefs.outputSourceMapFile.fullPath;

// Output CSS file should be relative to the source map
if (typeof prefs.options.sourceMap === "string") {
json.file = PathUtils.makePathRelative(cssFilePath, sourceMapFilePath);
}

// Replace backslashes in paths
json.sources = json.sources.map(function (source) {
return source.replace(/\\/g, "/");
});

// Output CSS file should be relative to the source map
if (typeof prefs.options.sourceMap === "string") {
json.file = PathUtils.makePathRelative(cssFilePath, sourceMapFilePath);

if (prefs.compiler === "ruby") {
var sourcesPrefix = PathUtils.makePathRelative(PathUtils.directory(cssFilePath), PathUtils.directory(sourceMapFilePath)),
mapPrefix = PathUtils.makePathRelative(PathUtils.directory(sourceMapFilePath), PathUtils.directory(cssFilePath));

json.sources = json.sources.map(function (source) {
return _normalizePath(sourcesPrefix + source);
});

css = css.replace(/\/\*# sourceMappingURL=(.*?) \*\//, function (_, url) {
return "/*# sourceMappingUrl=" + _normalizePath(mapPrefix + url) + " */";
});
}
}

// For some reason, sources are output relative to the CWD
// Add a sourceRoot to fix
// json.sourceRoot = PathUtils.makePathRelative(inputFile.parentPath, sourceMapFilePath);

// TODO read tab/space preference?
return JSON.stringify(json, null, " ");
}

function _makeSourceMapRelativeToOutput(prefs) {
if (typeof prefs.options.sourceMap === "string") {
var sourceMapPath = prefs.outputSourceMapFile.fullPath,
cssFilePath = prefs.outputCSSFile.fullPath;

// sourceMap should be relative to the output file
// This is only used when generating sourceMappingURL
return PathUtils.makePathRelative(sourceMapPath, cssFilePath);
}

return prefs.options.sourceMap;
return {
map: JSON.stringify(json, null, " "),
css: css
};
}

function _render(path, prefs) {
var deferred = new $.Deferred(),
options = prefs.options,
sourceMap = _makeSourceMapRelativeToOutput(prefs);
options = prefs.options;

var renderPromise = _nodeDomain.exec("render",
path,
Expand All @@ -111,12 +140,13 @@ define(function (require, exports, module) {
options.imagePath,
options.outputStyle,
options.sourceComments,
sourceMap,
prefs.outputSourceMapFile.fullPath,
prefs.compiler,
prefs.compass);

renderPromise.then(function (response) {
deferred.resolve(response.css, _fixSourceMap(response.map, prefs), response.error, response._compassOutFile);
var result = _fixSourceMapPaths(response.map, response.css, prefs);
deferred.resolve(result.css, result.map, response.error, response._compassOutFile);
}, deferred.reject);

return deferred.promise();
Expand Down Expand Up @@ -355,7 +385,6 @@ define(function (require, exports, module) {

var cssFile = prefs.outputCSSFile,
mapFile = prefs.outputSourceMapFile,
sourceMap = _makeSourceMapRelativeToOutput(prefs),
options = prefs.options,
previewPromise,
inMemoryFiles = _getInMemoryFiles(docs),
Expand All @@ -371,24 +400,25 @@ define(function (require, exports, module) {
options.imagePath,
options.outputStyle,
"map",
sourceMap,
prefs.outputSourceMapFile.fullPath,
prefs.compiler,
prefs.compass);

StatusBarUtil.showBusyStatus("Checking for errors");

previewPromise.then(function (response) {
var eventData = {
css: {
file: cssFile,
contents: response.css
},
sourceMap: {
file: mapFile,
contents: _fixSourceMap(response.map, prefs)
}
};

var result = _fixSourceMapPaths(response.map, response.css, prefs),
eventData = {
css: {
file: cssFile,
contents: result.css
},
sourceMap: {
file: mapFile,
contents: result.json
}
};

$(exports).triggerHandler("sourceMapPreviewEnd", [sassFile, eventData]);
_finishScan(sassFile, response.error);

Expand Down Expand Up @@ -418,7 +448,7 @@ define(function (require, exports, module) {
function killProcess() {
_nodeDomain.exec("killProcess");
}

// Register preferences
extensionPrefs.definePreference(PREF_ENABLED, "boolean", true)
.on("change", _prefChangeHandler);
Expand Down
2 changes: 1 addition & 1 deletion NestedStyleParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50, regexp: true */
/*global define, $, _parseRuleList: true */
/*global brackets, define, $, _parseRuleList: true */

// JSLint Note: _parseRuleList() is cyclical dependency, not a global function.
// It was added to this list to prevent JSLint warning about being used before being defined.
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion node/3.0.0/SASSDomain.js → node/2.0.2/SASSDomain.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var cp = require("child_process"),
os = require("os"),
path = require("path");

var DOMAIN = "sass-v3.0.0",
var DOMAIN = "sass-v2.0.2",
RE_NODE_SASS_WIN_DRIVE = /([a-z]:\\([a-z]:\\))/i;

var _domainManager,
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions node/2.0.2/node_modules/.bin/node-sass

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 618d6b2

Please sign in to comment.