debian-mirror-gitlab/scripts/frontend/startup_css/get_css_path.js
2021-09-04 01:27:46 +05:30

22 lines
634 B
JavaScript

const fs = require('fs');
const path = require('path');
const { memoize } = require('lodash');
const { PATH_ASSETS } = require('./constants');
const { die } = require('./utils');
const listAssetsDir = memoize(() => fs.readdirSync(PATH_ASSETS));
const getCSSPath = (prefix) => {
const matcher = new RegExp(`^${prefix}-[^-]+\\.css$`);
const cssPath = listAssetsDir().find((x) => matcher.test(x));
if (!cssPath) {
die(
`Could not find the CSS asset matching "${prefix}". Have you run "scripts/frontend/startup_css/setup.sh"?`,
);
}
return path.join(PATH_ASSETS, cssPath);
};
module.exports = { getCSSPath };