Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const log_1 = require("./log");
function optimize(value) {
    return value
        .split('\n')
        .filter(x => !x.startsWith('#'))
        .join('')
        .replace(/(\n|\t)+/gm, '')
        .replace(/( )+/gm, ' ');
}
function optimizeBody(path) {
    if (path.value.hasOwnProperty('quasis')) {
        const value = path.value;
        const quasis = value.quasis;
        quasis.forEach(x => {
            log_1.log('before: ', x);
            x.value.raw = optimize(x.value.raw);
            log_1.log('after: ', x);
        });
    }
    else {
        const value = path.value;
        value.value = optimize(value.value);
    }
    /**
     * @todo remove them... if this is possible, that would be swell
     */
    // quasis[0].value.raw = ''
    // value.quasis = [quasis[0]]
}
function optimizeIfBody(path, index) {
    // console.log(path)
    const { name } = path.key;
    if (name === 'body') {
        optimizeBody(path);
    }
}
function default_1() {
    return {
        visitor: {
            AssignmentExpression(path) {
                // @example eh.canada.moose = {}
                if (path.node.operator === '=') {
                    // @example eh.canada.moose is the left
                    const left = path.node.left;
                    const right = path.node.right;
                    if (left && left.property) {
                        // @example 'moose' is the name here
                        const lastPropertyName = left.property;
                        // ensuring we have `source` in order to find `body` safely
                        if (lastPropertyName.name === 'source') {
                            if (right && right.properties) {
                                right.properties.forEach(optimizeIfBody);
                            }
                        }
                    }
                }
            },
        },
    };
}
exports.default = default_1;
//# sourceMappingURL=index.js.map