sass-export
Version:
Exports Sass files to Json format, able to manage sections with annotations in comments.
33 lines • 1.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Utils = void 0;
const WRAPPER_CSS_ID = '#sass-export-id';
const UNWRAPPER_PATTERN = `${WRAPPER_CSS_ID}\\.(.+)\\s*\\{\\s*content:\\s*["'](.+)["']`;
class Utils {
static getDeclarationByName(declarations = [], name) {
let filtered = declarations.filter((declaration) => declaration.name === name);
return filtered[0];
}
static wrapCss(cssDeclaration, useInspect) {
if (useInspect) {
return `${WRAPPER_CSS_ID}._${cssDeclaration.name}{content:"#{inspect(${cssDeclaration.value})}";}`;
}
return `${WRAPPER_CSS_ID}._${cssDeclaration.name}{content:"#{${cssDeclaration.value}}";}`;
}
static removeDoubleQuotes(wrappedContent) {
wrappedContent = wrappedContent.replace(/"([^'"]+(?="'))"/, '$1');
return wrappedContent;
}
static unWrapValue(wrappedContent) {
wrappedContent = wrappedContent.replace(/\n/g, '');
let matches = wrappedContent.match(UNWRAPPER_PATTERN);
if (matches && matches.length > 2) {
return matches[2].trim();
}
else {
return '';
}
}
}
exports.Utils = Utils;
//# sourceMappingURL=utils.js.map