Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: sass/node-sass
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.13.0
Choose a base ref
...
head repository: sass/node-sass
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.13.1
Choose a head ref
  • 5 commits
  • 5 files changed
  • 3 contributors

Commits on Oct 21, 2019

  1. Fix #2394: sourceMap option should have consistent behaviour

    render() and renderSync() should return "map" property in the results
    only if source map has been enabled.
    saper committed Oct 21, 2019
    1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8498f70 View commit details

Commits on Oct 24, 2019

  1. Merge pull request #2754 from saper/no-map-if-not-requested

    Fix #2394: sourceMap option should have consistent behaviour
    xzyfer authored Oct 24, 2019
    Copy the full SHA
    fbc9ff5 View commit details

Commits on Nov 17, 2019

  1. doc: README example fix (#2787)

    Fix Unexpected token ) on the render example
    ZoranPandovski authored and nschonni committed Nov 17, 2019
    Copy the full SHA
    c6f2e5a View commit details

Commits on Jan 16, 2020

  1. Copy the full SHA
    338fd7a View commit details
  2. 4.13.1

    xzyfer committed Jan 16, 2020
    Copy the full SHA
    01db051 View commit details
Showing with 57 additions and 12 deletions.
  1. +5 −3 README.md
  2. +3 −1 lib/index.js
  3. +1 −1 package.json
  4. +8 −7 src/custom_importer_bridge.cpp
  5. +40 −0 test/api.js
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -311,9 +311,11 @@ Used to determine how many digits after the decimal will be allowed. For instanc
* Type: `Boolean | String | undefined`
* Default: `undefined`

**Special:** Setting the `sourceMap` option requires also setting the `outFile` option
Enables source map generation during `render` and `renderSync`.

Enables the outputting of a source map during `render` and `renderSync`. When `sourceMap === true`, the value of `outFile` is used as the target output location for the source map. When `typeof sourceMap === "string"`, the value of `sourceMap` will be used as the writing location for the file.
When `sourceMap === true`, the value of `outFile` is used as the target output location for the source map with the suffix `.map` appended. If no `outFile` is set, `sourceMap` parameter is ignored.

When `typeof sourceMap === "string"`, the value of `sourceMap` will be used as the writing location for the file.

### sourceMapContents

@@ -422,7 +424,7 @@ var result = sass.renderSync({
var result = someSyncFunction(url, prev);
return {file: result.path, contents: result.data};
}
}));
});

console.log(result.css);
console.log(result.map);
4 changes: 3 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
@@ -300,9 +300,11 @@ module.exports.render = function(opts, cb) {
var stats = endStats(result.stats);
var payload = {
css: result.css,
map: result.map,
stats: stats
};
if (result.map) {
payload.map = result.map;
}

if (cb) {
options.context.callback.call(options.context, null, payload);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-sass",
"version": "4.13.0",
"version": "4.13.1",
"libsass": "3.5.4",
"description": "Wrapper around libsass",
"license": "MIT",
15 changes: 8 additions & 7 deletions src/custom_importer_bridge.cpp
Original file line number Diff line number Diff line change
@@ -13,11 +13,12 @@ SassImportList CustomImporterBridge::post_process_return_value(v8::Local<v8::Val
imports = sass_make_import_list(array->Length());

for (size_t i = 0; i < array->Length(); ++i) {
v8::Local<v8::Value> value = Nan::Get(array, static_cast<uint32_t>(i)).ToLocalChecked();
v8::Local<v8::Value> value;
Nan::MaybeLocal<v8::Value> unchecked = Nan::Get(array, static_cast<uint32_t>(i));

if (!value->IsObject()) {
auto entry = sass_make_import_entry(0, 0, 0);
sass_import_set_error(entry, "returned array must only contain object literals", -1, -1);
if (!unchecked.ToLocal(&value) || !value->IsObject()) {
imports[i] = sass_make_import_entry(0, 0, 0);
sass_import_set_error(imports[i], "returned array must only contain object literals", -1, -1);
continue;
}

@@ -71,9 +72,9 @@ Sass_Import* CustomImporterBridge::check_returned_string(Nan::MaybeLocal<v8::Val
}

Sass_Import* CustomImporterBridge::get_importer_entry(const v8::Local<v8::Object>& object) const {
auto returned_file = Nan::Get(object, Nan::New<v8::String>("file").ToLocalChecked());
auto returned_contents = Nan::Get(object, Nan::New<v8::String>("contents").ToLocalChecked()).ToLocalChecked();
auto returned_map = Nan::Get(object, Nan::New<v8::String>("map").ToLocalChecked());
Nan::MaybeLocal<v8::Value> returned_file = Nan::Get(object, Nan::New<v8::String>("file").ToLocalChecked());
Nan::MaybeLocal<v8::Value> returned_contents = Nan::Get(object, Nan::New<v8::String>("contents").ToLocalChecked());
Nan::MaybeLocal<v8::Value> returned_map = Nan::Get(object, Nan::New<v8::String>("map").ToLocalChecked());
Sass_Import *err;

if ((err = check_returned_string(returned_file, "returned value of `file` must be a string")))
40 changes: 40 additions & 0 deletions test/api.js
Original file line number Diff line number Diff line change
@@ -63,6 +63,26 @@ describe('api', function() {
});
});

it('should not generate source map when not requested', function(done) {
sass.render({
file: fixture('simple/index.scss'),
sourceMap: false
}, function(error, result) {
assert.strictEqual(result.hasOwnProperty('map'), false, 'result has a map property');
done();
});
});

it('should not generate source map without outFile and no explicit path given', function(done) {
sass.render({
file: fixture('simple/index.scss'),
sourceMap: true
}, function(error, result) {
assert.strictEqual(result.hasOwnProperty('map'), false, 'result has a map property');
done();
});
});

it('should compile generate map with sourceMapRoot pass-through option', function(done) {
sass.render({
file: fixture('simple/index.scss'),
@@ -1348,6 +1368,26 @@ describe('api', function() {
done();
});

it('should not generate source map when not requested', function(done) {
var result = sass.renderSync({
file: fixture('simple/index.scss'),
sourceMap: false
});

assert.strictEqual(result.hasOwnProperty('map'), false, 'result has a map property');
done();
});

it('should not generate source map without outFile and no explicit path given', function(done) {
var result = sass.renderSync({
file: fixture('simple/index.scss'),
sourceMap: true
});

assert.strictEqual(result.hasOwnProperty('map'), false, 'result has a map property');
done();
});

it('should compile generate map with sourceMapRoot pass-through option', function(done) {
var result = sass.renderSync({
file: fixture('simple/index.scss'),