Skip to content

Commit

Permalink
Merge pull request #1 from pieh/updates-30435
Browse files Browse the repository at this point in the history
Fix failing tests and typo
  • Loading branch information
mjameswh authored Apr 26, 2021
2 parents cb24ab2 + eba2ecc commit 75761a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,6 @@ Object {
}
`;

exports[`npm package resource installs 2 resources, one prod & one dev: NPMPackage destroy 1`] = `
Object {
"_message": "Installed NPM package is-sorted@1.0.2",
"description": "A small module to check if an Array is sorted",
"id": "is-sorted",
"name": "is-sorted",
"version": "1.0.2",
}
`;

exports[`npm package resource installs 2 resources, one prod & one dev: NPMPackage update 1`] = `
Object {
"_message": "Installed NPM package is-sorted@1.0.2",
"description": "A small module to check if an Array is sorted",
"id": "is-sorted",
"name": "is-sorted",
"version": "1.0.2",
}
`;

exports[`package manager client commands generates the correct commands for npm 1`] = `
Array [
"install",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,26 @@ module.exports = class GatsbyThemeComponentShadowingResolverPlugin {
...DEFAULT_FILE_EXTENSIONS_CATEGORIES,
...extensionsCategory,
}
this.additionnalShadowExtensions = this.buildAdditionnalShadowExtensions()
this.additionalShadowExtensions = this.buildAdditionalShadowExtensions()
}

buildAdditionnalShadowExtensions() {
buildAdditionalShadowExtensions() {
const extensionsByCategory = _.groupBy(
this.extensions,
ext => this.extensionsCategory[ext.substring(1)] || `undefined`
)

const additionnalExtensions = []
const additionalExtensions = []
for (const [category, exts] of Object.entries(extensionsByCategory)) {
if (category === `undefined`) continue
for (const ext of exts) {
additionnalExtensions.push({ key: ext, value: exts })
additionalExtensions.push({ key: ext, value: exts })
}
}

// Sort extensions in reverse length order, so that something such as
// ".css.js" get caught before ".js"
return additionnalExtensions.sort(
return additionalExtensions.sort(
({ key: a }, { key: b }) => a.length <= b.length
)
}
Expand Down Expand Up @@ -284,23 +284,23 @@ module.exports = class GatsbyThemeComponentShadowingResolverPlugin {
}

getAcceptableShadowFileNames(componentName, originalRequestComponent) {
const matchingEntry = this.additionnalShadowExtensions.find(entry =>
const matchingEntry = this.additionalShadowExtensions.find(entry =>
componentName.endsWith(entry.key)
)

let additionnalNames = []
let additionalNames = []
if (matchingEntry) {
const baseName = componentName.slice(0, -matchingEntry.key.length)
additionnalNames = matchingEntry.value.map(ext => `${baseName}${ext}`)
additionalNames = matchingEntry.value.map(ext => `${baseName}${ext}`)
}

let legacyAdditionnalNames = []
let legacyAdditionalNames = []
if (originalRequestComponent) {
legacyAdditionnalNames = this.extensions.map(
legacyAdditionalNames = this.extensions.map(
ext => `${originalRequestComponent}${ext}`
)
}

return [componentName, ...additionnalNames, ...legacyAdditionnalNames]
return [componentName, ...additionalNames, ...legacyAdditionalNames]
}
}

0 comments on commit 75761a2

Please sign in to comment.