You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
851 B
JavaScript

"use strict";
const defaultValue = require("default-value");
const path = require("path");
// Yes, there is a good reason this is a separate module. In the future we may need to add more heuristics to determine whether a "CSS file" *really* is a CSS file, rather than just going off the filename, and this centralizes the checking logic we'd need to change for that. If this ever occurs, though, keep in mind that this function doesn't always get a *full* file object (sometimes it just gets an object with a filename), so any such heuristics would need to be able to deal with that.
module.exports = function (state) {
let targetExtensions = new Set(defaultValue(state.extensions, [ "css" ]));
return function isCss(item) {
let itemExtension = path.extname(item.file).replace(/^\./, "");
return targetExtensions.has(itemExtension);
};
};