UNPKG

1.35 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var graphql_codegen_core_1 = require("graphql-codegen-core");
4function cleanTemplateComments(template, debugFilename) {
5 if (debugFilename === void 0) { debugFilename = ''; }
6 graphql_codegen_core_1.debugLog("[cleanTemplateComments] called, looking for magic comments in " + debugFilename + "...");
7 if (template.match(/\/\*\s*gqlgen/gi)) {
8 graphql_codegen_core_1.debugLog("[cleanTemplateComments] Found magic comment 'gqlgen' in template " + debugFilename + "...", template);
9 var result = template
10 .replace(/.*({{.*}})/gi, function (all, group) {
11 if (all.toLowerCase().includes('gqlgen')) {
12 return all;
13 }
14 return all.replace(/{{/g, '\\{{');
15 })
16 .replace(/\/\*\s*gqlgen\s*(.*?)\s*\*\//gi, function (all, group) { return (group ? group : all); });
17 graphql_codegen_core_1.debugLog("[cleanTemplateComments] template " + debugFilename + " modified, result is: ", template);
18 return result;
19 }
20 graphql_codegen_core_1.debugLog("[cleanTemplateComments] " + debugFilename + " does not contains any magic comments, skipping...");
21 return template;
22}
23exports.cleanTemplateComments = cleanTemplateComments;
24//# sourceMappingURL=clean-template.js.map
\No newline at end of file