dist/src/read-code.js
function getSourceCode(fileName) {
    return __awaiter(this, void 0, void 0, function () {
        var code, codeCommentsRegex, importsRegex, imports;
        var _this = this;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, readFile(fileName, 'utf-8')];
                case 1:
                    code = _a.sent();
                    codeCommentsRegex = /(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(\/\/.*)/g;
                    code = code.replace(codeCommentsRegex, '');
                    importsRegex = /import "([^"]*)";/g;
                    imports = matches(importsRegex, code);
                    return [4 /*yield*/, Promise.all(imports.map(function (match) { return __awaiter(_this, void 0, void 0, function () {
                            var p, innerCode;
                            return __generator(this, function (_a) {
                                switch (_a.label) {
                                    case 0:
                                        p = path.resolve(fileName, '..', match.inner);
                                        return [4 /*yield*/, getSourceCode(p)];
                                    case 1:
                                        innerCode = _a.sent();
                                        // remove first line containing version
                                        innerCode = innerCode.replace(/^.*\n/, '');
                                        code = code.replace(match.full, innerCode);
                                        return [2 /*return*/];
                                }
                            });
                        }); }))];
                case 2:
                    _a.sent();
                    return [2 /*return*/, code];
            }
        });
    });
}
function getSourceCode(fileName) {
    return __awaiter(this, void 0, void 0, function () {
        var code, codeCommentsRegex, importsRegex, imports;
        var _this = this;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, readFile(fileName, 'utf-8')];
                case 1:
                    code = _a.sent();
                    codeCommentsRegex = /(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(\/\/.*)/g;
                    code = code.replace(codeCommentsRegex, '');
                    importsRegex = /import "([^"]*)";/g;
                    imports = matches(importsRegex, code);
                    return [4 /*yield*/, Promise.all(imports.map(function (match) { return __awaiter(_this, void 0, void 0, function () {
                            var p, innerCode;
                            return __generator(this, function (_a) {
                                switch (_a.label) {
                                    case 0:
                                        p = path.resolve(fileName, '..', match.inner);
                                        return [4 /*yield*/, getSourceCode(p)];
                                    case 1:
                                        innerCode = _a.sent();
                                        // remove first line containing version
                                        innerCode = innerCode.replace(/^.*\n/, '');
                                        code = code.replace(match.full, innerCode);
                                        return [2 /*return*/];
                                }
                            });
                        }); }))];
                case 2:
                    _a.sent();
                    return [2 /*return*/, code];
            }
        });
    });
}
function getSourceCode ( fileName ) { return __awaiter ( this , void 0 , void 0 , function ( ) { var code , codeCommentsRegex , importsRegex , imports ; var _this = this ; return __generator ( this , function ( _a ) { switch ( _a . label ) { case 0 : return [ 4 /*yield*/ , readFile ( fileName , 'utf-8' ) ] ; case 1 : code = _a . sent ( ) ; codeCommentsRegex = / (\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(\/\/.*) / g ; code = code . replace ( codeCommentsRegex , '' ) ; importsRegex = / import "([^"]*)"; / g ; imports = matches ( importsRegex , code ) ; return [ 4 /*yield*/ , Promise . all ( imports . map ( function ( match ) { return __awaiter ( _this , void 0 , void 0 , function ( ) { var p , innerCode ; return __generator ( this , function ( _a ) { switch ( _a . label ) { case 0 : p = path . resolve ( fileName , '..' , match . inner ) ; return [ 4 /*yield*/ , getSourceCode ( p ) ] ; case 1 : innerCode = _a . sent ( ) ; // remove first line containing version innerCode = innerCode . replace ( / ^.*\n / , '' ) ; code = code . replace ( match . full , innerCode ) ; return [ 2 /*return*/ ] ; } } ) ; } ) ; } ) ) ] ; case 2 : _a . sent ( ) ; return [ 2 /*return*/ , code ] ; } } ) ; } ) ; }
gets the source-code from the file
and parses all imports
gets the source - code from the file and parses all imports