Skip to content

Commit

Permalink
Move moduleToExtensionConversion config to known plugins JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
lfdebrux committed Nov 22, 2022
1 parent 5d04c3c commit d94ec48
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
8 changes: 7 additions & 1 deletion known-plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"@govuk-prototype-kit/step-by-step",
"hmrc-frontend",
"jquery"
]
],
"interned": {
"jquery": {
"scripts": ["/dist/jquery.js"],
"assets": ["/dist"]
}
}
}
}
11 changes: 5 additions & 6 deletions lib/extensions/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ const chokidar = require('chokidar')
const fse = require('fs-extra')
const { shadowNunjucks } = require('../build/config.json').paths

const knownPlugins = fse.readJsonSync(
path.join(projectDir, 'known-plugins.json')
)

// Generic utilities
const removeDuplicates = arr => [...new Set(arr)]
const filterOutParentAndEmpty = part => part && part !== '..'
Expand All @@ -57,12 +61,7 @@ const objectMap = (object, mapFn) => Object.keys(object).reduce((result, key) =>
// File utilities
const getPathFromProjectRoot = (...all) => path.join(...[projectDir].concat(all))
const pathToPackageConfigFile = packageName => getPathFromProjectRoot('node_modules', packageName, 'govuk-prototype-kit.config.json')
const moduleToExtensionConversion = {
jquery: {
scripts: ['/dist/jquery.js'],
assets: ['/dist']
}
}
const moduleToExtensionConversion = knownPlugins.plugins.interned

const readJsonFile = (filePath) => {
return JSON.parse(fs.readFileSync(filePath, 'utf8'))
Expand Down

0 comments on commit d94ec48

Please sign in to comment.