diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-26 21:11:43 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-26 21:11:43 +0300 |
commit | bc75527dca77b2b72331ac6cbd5928d5b8c0c419 (patch) | |
tree | 000196faadb05f6e2ff60c08865b1a09506e5522 /scripts/frontend | |
parent | c82ca12a1c5a359325cb45aaf01b483d1fa0efcb (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts/frontend')
-rwxr-xr-x | scripts/frontend/check_page_bundle_mixins_css_for_sideeffects.js | 36 |
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); |