Skip to content

Commit

Permalink
fix(): when multipleScopeVars.length is one and path is Array , emit …
Browse files Browse the repository at this point in the history
…error
  • Loading branch information
GitOfZGT committed Sep 28, 2021
1 parent 757559e commit 14c20aa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zougt/some-loader-utils",
"version": "1.3.0",
"version": "1.3.1",
"description": "implementation for less-loader or sass-loader. Compiles Less or sass to CSS.",
"license": "MIT",
"repository": "GitOfZGT/some-loader-utils",
Expand Down
23 changes: 11 additions & 12 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,6 @@ const getAllStyleVarFiles = (loaderContext, options) => {
if (Array.isArray(styleVarFiles)) {
if (styleVarFiles.length === 1) {
allStyleVarFiles = styleVarFiles.map((item) => {
if (
!item.path ||
typeof item.path !== 'string' ||
!fs.existsSync(item.path)
) {
loaderContext.emitError(
new Error(
`Not found path: ${item.path} in multipleScopeVars`
)
);
return { scopeName: '', path: '' };
}
if (Array.isArray(item.path)) {
const exist = item.path.every((pathstr) => {
const exists = pathstr && fs.existsSync(pathstr);
Expand All @@ -37,6 +25,17 @@ const getAllStyleVarFiles = (loaderContext, options) => {
if (!exist) {
return { scopeName: '', path: '' };
}
} else if (
!item.path ||
typeof item.path !== 'string' ||
!fs.existsSync(item.path)
) {
loaderContext.emitError(
new Error(
`Not found path: ${item.path} in multipleScopeVars`
)
);
return { scopeName: '', path: '' };
}
return { ...item, scopeName: '' };
});
Expand Down

0 comments on commit 14c20aa

Please sign in to comment.