aboutsummaryrefslogtreecommitdiff
path: root/scripts/theme-studio/inline-strip.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/theme-studio/inline-strip.mjs')
-rw-r--r--scripts/theme-studio/inline-strip.mjs15
1 files changed, 15 insertions, 0 deletions
diff --git a/scripts/theme-studio/inline-strip.mjs b/scripts/theme-studio/inline-strip.mjs
new file mode 100644
index 000000000..112d55ce6
--- /dev/null
+++ b/scripts/theme-studio/inline-strip.mjs
@@ -0,0 +1,15 @@
+// Shared by the inline-integrity tests (test-colormath.mjs, test-app-core.mjs,
+// test-app-util.mjs). Mirrors strip_exports in generate.py: drop top-level
+// export/import lines (a pure module may import a peer for its own unit tests,
+// while the inlined page copy relies on that peer already being present), then
+// rstrip. The page is asserted to carry the stripped body verbatim, so this MUST
+// stay aligned with generate.py's strip_exports -- one definition keeps the three
+// test copies from drifting apart.
+//
+// (This file matches the `*.mjs` test glob in run-tests.sh; it carries no tests,
+// so it contributes zero to the count.)
+export const stripInlinedBody = (s) =>
+ s.split('\n')
+ .filter((l) => !(l.startsWith('export') || l.startsWith('import')))
+ .join('\n')
+ .replace(/\s+$/, '');