summaryrefslogtreecommitdiff
path: root/scripts/frontend/check_page_bundle_mixins_css_for_sideeffects.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 01:45:44 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 01:45:44 +0000
commit85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch)
tree9160f299afd8c80c038f08e1545be119f5e3f1e1 /scripts/frontend/check_page_bundle_mixins_css_for_sideeffects.js
parent15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff)
downloadgitlab-ce-85dc423f7090da0a52c73eb66faf22ddb20efff9.tar.gz
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
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);