@acot/config
Advanced tools
Comparing version 0.0.3 to 0.0.4-canary.0
@@ -6,2 +6,6 @@ # Change Log | ||
## [0.0.4-canary.0](https://github.com/acot-a11y/acot/compare/@acot/config@0.0.3...@acot/config@0.0.4-canary.0) (2020-12-29) | ||
**Note:** Version bump only for package @acot/config | ||
## [0.0.3](https://github.com/acot-a11y/acot/compare/@acot/config@0.0.3-canary.2...@acot/config@0.0.3) (2020-12-22) | ||
@@ -8,0 +12,0 @@ |
@@ -104,2 +104,3 @@ "use strict"; | ||
delete cfg.runner; | ||
delete cfg.reporter; | ||
delete cfg.overrides; | ||
@@ -106,0 +107,0 @@ return config; |
@@ -7,7 +7,4 @@ "use strict"; | ||
exports.ConfigRouter = void 0; | ||
const glob_to_regexp_1 = __importDefault(require("glob-to-regexp")); | ||
const globOptions = { | ||
globstar: true, | ||
extended: true, | ||
}; | ||
const micromatch_1 = __importDefault(require("micromatch")); | ||
const merger_1 = require("./merger"); | ||
class ConfigRouter { | ||
@@ -19,18 +16,21 @@ constructor(config) { | ||
var _a; | ||
const test = (pattern, path) => glob_to_regexp_1.default(pattern, globOptions).test(path); | ||
const entry = (_a = this._config.overrides) === null || _a === void 0 ? void 0 : _a.find((config) => { | ||
var _a; | ||
let found = ((_a = config.paths) !== null && _a !== void 0 ? _a : []).includes(path); | ||
const test = (pattern, path) => micromatch_1.default.isMatch(path, pattern); | ||
const entries = (_a = this._config.overrides) === null || _a === void 0 ? void 0 : _a.filter((entry) => { | ||
let found = false; | ||
// include | ||
if (!found && config.include != null) { | ||
found = config.include.some((pattern) => test(pattern, path)); | ||
if (entry.include != null) { | ||
found = entry.include.some((pattern) => test(pattern, path)); | ||
} | ||
// exclude | ||
if (found && config.exclude != null) { | ||
found = config.exclude.every((pattern) => !test(pattern, path)); | ||
if (found && entry.exclude != null) { | ||
found = entry.exclude.every((pattern) => !test(pattern, path)); | ||
} | ||
return found; | ||
}); | ||
if (entry != null) { | ||
return entry; | ||
if (entries != null && entries.length > 0) { | ||
return entries.reduce((acc, cur) => merger_1.mergeConfig(acc, cur), { | ||
rules: this._config.rules, | ||
presets: this._config.presets, | ||
headers: this._config.headers, | ||
}); | ||
} | ||
@@ -37,0 +37,0 @@ return this._config; |
@@ -18,8 +18,2 @@ import Ajv = require('ajv'); | ||
}; | ||
paths: { | ||
items: { | ||
type: string; | ||
}; | ||
type: string; | ||
}; | ||
presets: { | ||
@@ -39,2 +33,3 @@ items: { | ||
overrides?: undefined; | ||
paths?: undefined; | ||
reporter?: undefined; | ||
@@ -73,8 +68,2 @@ runner?: undefined; | ||
}; | ||
paths: { | ||
items: { | ||
type: string; | ||
}; | ||
type: string; | ||
}; | ||
presets: { | ||
@@ -109,3 +98,2 @@ items: { | ||
headers?: undefined; | ||
paths?: undefined; | ||
presets?: undefined; | ||
@@ -119,2 +107,8 @@ rules?: undefined; | ||
}; | ||
paths: { | ||
items: { | ||
type: string; | ||
}; | ||
type: string; | ||
}; | ||
reporter: { | ||
@@ -180,3 +174,2 @@ anyOf: ({ | ||
headers?: undefined; | ||
paths?: undefined; | ||
presets?: undefined; | ||
@@ -183,0 +176,0 @@ rules?: undefined; |
@@ -32,8 +32,2 @@ "use strict"; | ||
}, | ||
paths: { | ||
items: { | ||
type: 'string', | ||
}, | ||
type: 'array', | ||
}, | ||
presets: { | ||
@@ -79,8 +73,2 @@ items: { | ||
}, | ||
paths: { | ||
items: { | ||
type: 'string', | ||
}, | ||
type: 'array', | ||
}, | ||
presets: { | ||
@@ -119,2 +107,8 @@ items: { | ||
}, | ||
paths: { | ||
items: { | ||
type: 'string', | ||
}, | ||
type: 'array', | ||
}, | ||
reporter: { | ||
@@ -121,0 +115,0 @@ anyOf: [ |
{ | ||
"name": "@acot/config", | ||
"version": "0.0.3", | ||
"version": "0.0.4-canary.0", | ||
"description": "A module to manipulate configs of acot.", | ||
"homepage": "https://github.com/acot-a11y/acot/tree/master/packages/config", | ||
"homepage": "https://github.com/acot-a11y/acot/tree/main/packages/config", | ||
"bugs": { | ||
@@ -32,2 +32,3 @@ "url": "https://github.com/acot-a11y/acot/issues" | ||
"rootDir": "src", | ||
"testEnvironment": "node", | ||
"testMatch": [ | ||
@@ -38,8 +39,8 @@ "**/__tests__/**/*.test.ts?(x)" | ||
"dependencies": { | ||
"@acot/core": "0.0.3", | ||
"@acot/module-loader": "0.0.3", | ||
"@acot/reporter": "0.0.3", | ||
"@acot/runner": "0.0.3", | ||
"@acot/types": "0.0.3", | ||
"@acot/utils": "0.0.3", | ||
"@acot/core": "0.0.4-canary.0", | ||
"@acot/module-loader": "0.0.4-canary.0", | ||
"@acot/reporter": "0.0.4-canary.0", | ||
"@acot/runner": "0.0.4-canary.0", | ||
"@acot/types": "0.0.4-canary.0", | ||
"@acot/utils": "0.0.4-canary.0", | ||
"ajv": "^6.12.3", | ||
@@ -49,4 +50,4 @@ "cosmiconfig": "^7.0.0", | ||
"deepmerge": "^4.2.2", | ||
"glob-to-regexp": "^0.4.1", | ||
"is-plain-object": "^5.0.0", | ||
"micromatch": "^4.0.2", | ||
"path-type": "^4.0.0", | ||
@@ -56,3 +57,3 @@ "resolve-from": "^5.0.0" | ||
"devDependencies": { | ||
"@types/glob-to-regexp": "^0.4.0", | ||
"@types/micromatch": "^4.0.1", | ||
"param-case": "^3.0.3", | ||
@@ -64,3 +65,3 @@ "typescript-json-validator": "^2.4.2" | ||
}, | ||
"gitHead": "bfc184385ad43fa7ff3fd3e52709fcb25e66587d" | ||
"gitHead": "d04b64541cb3226356998ee7cba234ffc48fa874" | ||
} |
49337
1197
+ Addedmicromatch@^4.0.2
+ Added@acot/core@0.0.4-canary.0(transitive)
+ Added@acot/factory@0.0.4-canary.0(transitive)
+ Added@acot/find-chrome@0.0.4-canary.0(transitive)
+ Added@acot/html-pickup@0.0.4-canary.0(transitive)
+ Added@acot/logger@0.0.4-canary.0(transitive)
+ Added@acot/module-loader@0.0.4-canary.0(transitive)
+ Added@acot/reporter@0.0.4-canary.0(transitive)
+ Added@acot/runner@0.0.4-canary.0(transitive)
+ Added@acot/schema-validator@0.0.4-canary.0(transitive)
+ Added@acot/types@0.0.4-canary.0(transitive)
+ Added@acot/utils@0.0.4-canary.0(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedmicromatch@4.0.7(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedto-regex-range@5.0.1(transitive)
- Removedglob-to-regexp@^0.4.1
- Removed@acot/connection@0.0.3(transitive)
- Removed@acot/core@0.0.3(transitive)
- Removed@acot/factory@0.0.3(transitive)
- Removed@acot/find-chrome@0.0.3(transitive)
- Removed@acot/html-pickup@0.0.3(transitive)
- Removed@acot/logger@0.0.3(transitive)
- Removed@acot/module-loader@0.0.3(transitive)
- Removed@acot/reporter@0.0.3(transitive)
- Removed@acot/runner@0.0.3(transitive)
- Removed@acot/schema-validator@0.0.3(transitive)
- Removed@acot/types@0.0.3(transitive)
- Removed@acot/utils@0.0.3(transitive)
- Removed@hapi/hoek@9.3.0(transitive)
- Removed@hapi/topo@5.1.0(transitive)
- Removed@sideway/address@4.1.5(transitive)
- Removed@sideway/formula@3.0.1(transitive)
- Removed@sideway/pinpoint@2.0.0(transitive)
- Removedaxios@0.21.4(transitive)
- Removedcross-spawn@7.0.3(transitive)
- Removedexeca@4.1.0(transitive)
- Removedfollow-redirects@1.15.6(transitive)
- Removedglob-to-regexp@0.4.1(transitive)
- Removedhuman-signals@1.1.1(transitive)
- Removedis-stream@2.0.1(transitive)
- Removedisexe@2.0.0(transitive)
- Removedjoi@17.13.3(transitive)
- Removedmerge-stream@2.0.0(transitive)
- Removedminimist@1.2.8(transitive)
- Removednpm-run-path@4.0.1(transitive)
- Removedpath-key@3.1.1(transitive)
- Removedrxjs@6.6.7(transitive)
- Removedshebang-command@2.0.0(transitive)
- Removedshebang-regex@3.0.0(transitive)
- Removedstrip-final-newline@2.0.0(transitive)
- Removedtslib@1.14.1(transitive)
- Removedwait-on@5.3.0(transitive)
- Removedwhich@2.0.2(transitive)
Updated@acot/core@0.0.4-canary.0
Updated@acot/runner@0.0.4-canary.0
Updated@acot/types@0.0.4-canary.0
Updated@acot/utils@0.0.4-canary.0