2017-03-05 17:29:46 +00:00
|
|
|
"use strict";
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
|
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
|
|
});
|
|
|
|
};
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
const plugins = require("./smartsass.plugins");
|
|
|
|
class Smartsass {
|
|
|
|
constructor(optionsArg) {
|
2017-03-11 23:55:34 +00:00
|
|
|
this.includePaths = [];
|
2017-03-05 17:29:46 +00:00
|
|
|
this.entryFilePath = optionsArg.entryFilePath;
|
2017-03-11 23:55:34 +00:00
|
|
|
if (optionsArg.includePaths) {
|
|
|
|
for (let includePath of optionsArg.includePaths) {
|
|
|
|
this.includePaths.push(includePath);
|
|
|
|
}
|
|
|
|
}
|
2017-03-05 17:29:46 +00:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* renders the Smartsass classes' entryfile and returns result as string
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
let done = plugins.smartq.defer();
|
|
|
|
plugins.sass.render({
|
2017-03-11 23:55:34 +00:00
|
|
|
file: this.entryFilePath,
|
|
|
|
includePaths: this.includePaths
|
2017-03-05 17:29:46 +00:00
|
|
|
}, function (err, result) {
|
|
|
|
if (err) {
|
|
|
|
console.log(err);
|
|
|
|
done.reject(err);
|
|
|
|
}
|
|
|
|
done.resolve(result);
|
|
|
|
});
|
|
|
|
return done.promise;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* renders and stores
|
|
|
|
*/
|
|
|
|
renderAndStore(outputFilePath) {
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
let result = yield this.render();
|
|
|
|
yield plugins.smartfile.memory.toFs(result.css.toString(), outputFilePath);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.Smartsass = Smartsass;
|
2017-03-11 23:55:34 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUEsK0NBQThDO0FBVTlDO0lBR0UsWUFBWSxVQUF3QztRQUZwRCxpQkFBWSxHQUFHLEVBQUUsQ0FBQTtRQUdmLElBQUksQ0FBQyxhQUFhLEdBQUcsVUFBVSxDQUFDLGFBQWEsQ0FBQTtRQUM3QyxFQUFFLENBQUEsQ0FBQyxVQUFVLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQztZQUMzQixHQUFHLENBQUMsQ0FBQyxJQUFJLFdBQVcsSUFBSSxVQUFVLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQztnQkFDaEQsSUFBSSxDQUFDLFlBQVksQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLENBQUE7WUFDckMsQ0FBQztRQUNILENBQUM7SUFDSCxDQUFDO0lBRUQ7O09BRUc7SUFDSCxNQUFNO1FBQ0osSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxLQUFLLEVBQXVCLENBQUE7UUFDdEQsT0FBTyxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUM7WUFDbEIsSUFBSSxFQUFFLElBQUksQ0FBQyxhQUFhO1lBQ3hCLFlBQVksRUFBRSxJQUFJLENBQUMsWUFBWTtTQUNoQyxFQUFFLFVBQVUsR0FBRyxFQUFFLE1BQU07WUFDdEIsRUFBRSxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQzt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