UNPKG

@manuth/woltlab-compiler

Version:

A compiler for generating WoltLab-Package `.tar` Archives and other WoltLab-Package Components

52 lines 1.87 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 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) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import fs from "fs-extra"; import main from "get-sass-vars"; import path from "upath"; const { readFileSync } = fs; const { dirname } = path; /** * Provides the functionality to parse `sass`-variable files. */ export class SassVariableParser { /** * Provides the functionality to parse an scss-file. * * @param fileName * The filename of the scss-file to parse. */ constructor(fileName) { this.fileName = fileName; } /** * Parses the scss-file. * * @returns * The variables inside the scss-file. */ Parse() { return __awaiter(this, void 0, void 0, function* () { let variables = yield main(readFileSync(this.fileName).toString(), { sassOptions: { includePaths: [ dirname(this.fileName) ] } }); return Object.fromEntries(Object.entries(variables).map((entry) => { return [ entry[0].replace(/^\$/, ""), entry[1] ]; })); }); } } //# sourceMappingURL=SassVariableParser.js.map