'use strict'

let sass = require('node-sass')

/*
 * Transform SASS to CSS.
 * @public
 * @param {string} folderPath - Path to the folder containing the SASS file.
 * @param {string} str - SASS.
 * @param {Object} opts - Options for the task.
 * @param {function} next - The callback that handles the response. Receives the following properties: err, css.
 */
module.exports = function(folderPath, str, opts, next) {

	// Dismiss sourceMap when output should be optimized
	let map = (opts.optimize===true ? false : true)

	sass.render({

		data              : str,
		includePaths      : [ folderPath ],
		sourceMap         : map,
		sourceMapEmbed    : true,
		sourceMapContents : true

	}, (err, result) => {

		if (err!=null) {
			next(err, null)
			return false
		}

		next(null, result.css.toString())

	})

}
@@ -618,17 +618,23 @@
       : 
-m
+sourceM
 ap,%0A%09%09so
@@ -651,20 +651,25 @@
 ed    : 
-true
+sourceMap
 ,%0A%09%09sour
@@ -684,20 +684,25 @@
 tents : 
-true
+sourceMap
 %0A%0A%09%7D, (e

Disable inline source map when optimization enabled