.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / lib / isPathIgnored.js
1 /* @flow */
2 "use strict";
3 const micromatch = require("micromatch");
4 const path = require("path");
5
6 // To find out if a path is ignored, we need to load the config,
7 // which may have an ignoreFiles property. We then check the path
8 // against these.
9 module.exports = function(
10   stylelint /*: stylelint$internalApi*/,
11   filePathArg /*:: ?: string*/
12 ) /*: Promise<boolean>*/ {
13   const filePath = filePathArg; // to please Flow
14   if (!filePath) {
15     return Promise.resolve(false);
16   }
17
18   return stylelint.getConfigForFile(filePath).then(result => {
19     const config = result.config;
20     const absoluteFilePath = path.isAbsolute(filePath)
21       ? filePath
22       : path.resolve(process.cwd(), filePath);
23     if (micromatch(absoluteFilePath, config.ignoreFiles).length) {
24       return true;
25     }
26     return false;
27   });
28 };