smartsass/dist/index.js

58 lines
3.7 KiB
JavaScript
Raw Normal View History

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
}
2017-03-12 09:59:21 +00:00
/**
* add further include paths
*/
addIncludePaths(includePathsArray) {
for (let includePath of includePathsArray) {
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-12 09:59:21 +00:00
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJd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