Permalink
Browse files

Fix: Find modules inside configurations

The main difference when installing webhint globally is that
`node_modules` content is not really flatten as the user needs to
install each package separatelly. This can cause some problems
findinging dependencies when they are nested. E.g.:
`configuration-development` downloads also
`configuration-progressive-webapps` but while this package will be at
the same level when installing webhint locally, when installing globally
it will be under `configuration-development`'s `node_modules` folder.

This change makes possible to find the packages under these
circumstances.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Fix #1437
  • Loading branch information...
molant committed Nov 8, 2018
1 parent 356dfa4 commit 5d1bf635a51f4a8fce7096041dcd8bc061a9eeec
Showing with 5 additions and 5 deletions.
  1. +3 −3 packages/hint/src/lib/config.ts
  2. +2 −2 packages/hint/src/lib/utils/resource-loader.ts
@@ -66,7 +66,7 @@ const loadPackageJSONConfigFile = (filePath: string): UserConfig => {
* Configurations for `extends` are applied left to right.
*
*/
const composeConfig = (userConfig: UserConfig) => {
const composeConfig = (userConfig: UserConfig, parentConfig = '') => {
/*
* If an `extends` property is defined, it represents a configuration package to use as
* a "parent". Load the configuration and merge recursively.
@@ -79,13 +79,13 @@ const composeConfig = (userConfig: UserConfig) => {
}
const configurations = userConfig.extends.map((config) => {
const loadedConfiguration = resourceLoader.loadConfiguration(config);
const loadedConfiguration = resourceLoader.loadConfiguration(config, [parentConfig]);
if (!validateConfig(loadedConfiguration)) {
throw new Error(`Configuration package "${config}" is not valid`);
}
return composeConfig(loadedConfiguration);
return composeConfig(loadedConfiguration, config);
});
const finalConfig: UserConfig = mergeWith({}, ...configurations, userConfig, (objValue: any, srcValue: any) => {
@@ -451,8 +451,8 @@ export const loadHint = (hintId: string, configurations?: string[]): IHintConstr
return loadResource(hintId, ResourceType.hint, configurations);
};
export const loadConfiguration = (configurationId: string) => {
return loadResource(configurationId, ResourceType.configuration);
export const loadConfiguration = (configurationId: string, configurations?: string[]) => {
return loadResource(configurationId, ResourceType.configuration, configurations);
};
/** Returns all the resources from a `HintConfig` */

0 comments on commit 5d1bf63

Please sign in to comment.