UNPKG

iwa-cli

Version:

An ImmutableWebApp CLI using oclif and cosmiconfig

18 lines (17 loc) 743 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.hasIWAConfig = exports.removeIWA = exports.replaceIWA = exports.getInjectedIwaConfigRegex = void 0; exports.getInjectedIwaConfigRegex = /(?<=<script id="iwa">)([\s\S]*?)(?=<\/script>)/gm; function replaceIWA(input, data) { return input.replace(exports.getInjectedIwaConfigRegex, `window.env = ${JSON.stringify(data)}`); } exports.replaceIWA = replaceIWA; function removeIWA(input) { return input.replace(exports.getInjectedIwaConfigRegex, ''); } exports.removeIWA = removeIWA; function hasIWAConfig(input) { const match = input.match(exports.getInjectedIwaConfigRegex); return match && match[0] !== ''; } exports.hasIWAConfig = hasIWAConfig;