Skip to content

Commit

Permalink
[#46] feat: add support for ignore files
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenisx committed Jul 24, 2022
1 parent 8af1406 commit 1696c73
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 7 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ This Extension supports the following properties as of now:

| **Setting** | **Description** | **Type** | **Example** | **Default** |
|-------------------------------|--------------------------------------------------------------|----------|--------------------------------------------|---------------------------------------------------------|
| `cssvar.files` | Relative/Absolute paths to CSS variable file sources | string[] | ["src/**/*.css"] | [**/*.css] | |
| `cssvar.files` | Relative/Absolute paths to CSS variable file sources | string[] | ["input.css"] | [**/*.css] | |
| `cssvar.files` | Relative/Absolute paths to file/folder sources to be ignored | string[] | ["input.css"] | [**/*.css] | |
| `cssvar.extensions` | File extensions for which IntelliSense will be enabled | string[] | [<br>&nbsp;&nbsp;"css",<br>&nbsp;&nbsp;"scss",<br>&nbsp;&nbsp;"jsx"<br>] | [<br>&nbsp;&nbsp;"css",<br>&nbsp;&nbsp;"scss",<br>&nbsp;&nbsp;"tsx",<br>&nbsp;&nbsp;"jsx"<br>] |
| `cssvar.themes`<br>Helps to bucket CSS variables based on themes used in any project | CSS Theme classnames used in source files | string[] | [<br>&nbsp;&nbsp;"dark",<br>&nbsp;&nbsp;"dim"<br>] | [] |
| `cssvar.excludeThemedVariables`<br>If true, hides duplicate theme variables from the list | Exclude themed variables to remove unnecessary duplicates | boolean | | false |
Expand All @@ -56,10 +57,6 @@ This Extension supports the following properties as of now:

## Screeshots:

### How to Install
![How to install](https://user-images.githubusercontent.com/11786283/113474149-bdc37380-948b-11eb-847d-4c031912b9f4.gif)


### Working Example
![Working Example](https://user-images.githubusercontent.com/11786283/112746381-07174d00-8fcc-11eb-82eb-d9b27540a956.gif)

Expand Down
1 change: 1 addition & 0 deletions examples/multi-root/multi-root.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"proj-2": true,
"proj-3": true,
},
"cssvar.files": ["*.css"],
"cssvar.enableGotoDef": true
}
}
3 changes: 3 additions & 0 deletions examples/multi-root/proj-1/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cssvar.ignore": ["broken.css"]
}
3 changes: 3 additions & 0 deletions examples/multi-root/proj-1/broken.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:root {
--blue #333;
}
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@
]
]
},
"cssvar.ignore": {
"type": "array",
"default": [],
"items": {
"type": "string"
},
"markdownDescription": "Relative/Absolute paths to file/folder sources to ignore",
"scope": "resource",
"examples": [
[
"**/node_modules/**",
"styles/ignore.css"
]
]
},
"cssvar.extensions": {
"type": "array",
"default": [],
Expand Down
4 changes: 3 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export type SupportedExtensionNames =
| "javascriptreact";

export interface Config {
files: string[] | Record<string, string[]>;
files: string[];
ignore: string[];
extensions: SupportedExtensionNames[];
themes: string[];
postcssPlugins: string[];
Expand All @@ -56,6 +57,7 @@ export interface Config {

export const DEFAULT_CONFIG: Config = {
files: ["**/*.css"],
ignore: ["**/node_modules/**"],
extensions: [...CSS_IDS],
themes: [],
postcssPlugins: [],
Expand Down
4 changes: 3 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ export async function setup(): Promise<{
switch (key) {
case "files": {
const value = getConfigValue(_config, key);
const ignoreList = getConfigValue(_config, "ignore");
const entries = await fastGlob(<string[]>value, {
cwd: resourcePath,
ignore: ignoreList,
});
config[fsPathKey][key] = entries.map((path: string) =>
resolve(resourcePath, path)
Expand All @@ -76,7 +78,7 @@ export async function setup(): Promise<{
const value = getConfigValue(_config, key);
config[fsPathKey][key] = value.map(ext => {
const _ext = ext.startsWith(".")
? (ext.substr(1) as SupportedExtensionNames)
? (ext.substring(1) as SupportedExtensionNames)
: ext;
return mapShortToFullExtension(_ext);
});
Expand Down

0 comments on commit 1696c73

Please sign in to comment.