Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/frontend/check_page_bundle_mixins_css_for_sideeffects.js')
-rwxr-xr-xscripts/frontend/check_page_bundle_mixins_css_for_sideeffects.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/scripts/frontend/check_page_bundle_mixins_css_for_sideeffects.js b/scripts/frontend/check_page_bundle_mixins_css_for_sideeffects.js
new file mode 100755
index 00000000000..a2bb9f56d84
--- /dev/null
+++ b/scripts/frontend/check_page_bundle_mixins_css_for_sideeffects.js
@@ -0,0 +1,36 @@
+#!/usr/bin/env node
+
+if (process.env.RAILS_ENV !== 'production') {
+ console.log(
+ `RAILS_ENV is not set to 'production': ${process.env.RAILS_ENV} - Not executing check`,
+ );
+ process.exit(0);
+}
+
+const path = require('path');
+const fs = require('fs');
+const glob = require('glob');
+const pjs = require('postcss');
+
+const paths = glob.sync('public/assets/page_bundles/_mixins_and_variables_and_functions*.css', {
+ cwd: path.join(__dirname, '..', '..'),
+});
+
+if (!paths[0]) {
+ console.log('Could not find mixins test file');
+ process.exit(1);
+}
+
+console.log(`Checking ${paths[0]} for side effects`);
+
+const file = fs.readFileSync(paths[0], 'utf-8');
+
+const parsed = pjs.parse(file);
+
+if (parsed.nodes.every(node => ['comment', 'atrule'].includes(node.type))) {
+ console.log('The file does not introduce any side effects, we are all good.');
+ process.exit(0);
+}
+
+console.log(`At least one unwanted style was introduced.`);
+process.exit(1);