Skip to content

Commit

Permalink
Merge pull request #2385 from alphagov/bug-fixes
Browse files Browse the repository at this point in the history
Various bug fixes and code issues
  • Loading branch information
colinrotherham authored Feb 28, 2024
2 parents 75f9623 + 77b7943 commit e6eec53
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions lib/plugins/plugin-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function validateMetaUrls (metaUrls) {
return
}

if (typeof metaUrls !== 'object') {
if (typeof metaUrls !== 'object' || Array.isArray(metaUrls)) {
errors.push('The meta.urls must be an object if entered')
return
}
Expand Down Expand Up @@ -124,7 +124,7 @@ function validateMetaUrls (metaUrls) {
function validateMeta (meta) {
const metaKeys = ['urls', 'description']

if (typeof meta !== 'object') {
if (typeof meta !== 'object' || Array.isArray(meta)) {
errors.push('The meta must be an object if entered')
return
}
Expand All @@ -143,7 +143,7 @@ function validateMeta (meta) {
}

function validatePluginDependency (key, configEntry) {
if (typeof configEntry === 'string') {
if (typeof configEntry !== 'object' || Array.isArray(configEntry)) {
return
}
// Can be a string, but if an object, the packageName must be a string
Expand Down Expand Up @@ -238,7 +238,7 @@ async function validatePlugin (executionPath, argv) {
errors.push('The plugin does not have a govuk-prototype-kit.config.json file, all plugins must have this file to be valid.')
}
})
if (!errors.length > 0) {
if (!errors.length) {
console.log()
console.log(ansiColors.green('The plugin config is valid.'))
console.log()
Expand Down
2 changes: 1 addition & 1 deletion lib/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function storeData (input, data) {
let val = input[i]

// Delete values when users unselect checkboxes
if (val === '_unchecked' || val === ['_unchecked']) {
if (val === '_unchecked') {
delete data[i]
continue
}
Expand Down
2 changes: 1 addition & 1 deletion migrator/file-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async function deleteDirectoryIfEmpty (partialPath) {
}
const dirContents = await fsp.readdir(dirPath)
if (dirContents.length === 0) {
return await deleteDirectory(dirPath, undefined)
return await deleteDirectory(dirPath)
}
return false
}
Expand Down
2 changes: 1 addition & 1 deletion migrator/migration-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ async function deleteUnusedDirectories (directoriesToDelete) {
return true
}
const reporter = await addReporter(`Remove unused directory ${dir}`)
const result = await deleteDirectory(dirPath, { recursive: true })
const result = await deleteDirectory(dirPath)
await reporter(result)
return result
}))
Expand Down
4 changes: 2 additions & 2 deletions migrator/migration-steps.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ describe('migration steps', () => {
expect(result).toBeTruthy()

expect(fileHelpers.deleteDirectory).toHaveBeenCalledTimes(2)
expect(fileHelpers.deleteDirectory).toHaveBeenNthCalledWith(1, path.join(projectDir, directoriesToDelete[0]), { recursive: true })
expect(fileHelpers.deleteDirectory).toHaveBeenNthCalledWith(2, path.join(projectDir, directoriesToDelete[1]), { recursive: true })
expect(fileHelpers.deleteDirectory).toHaveBeenNthCalledWith(1, path.join(projectDir, directoriesToDelete[0]))
expect(fileHelpers.deleteDirectory).toHaveBeenNthCalledWith(2, path.join(projectDir, directoriesToDelete[1]))

expect(mockReporter).toHaveBeenCalledTimes(3)
expect(mockReporter).toHaveBeenNthCalledWith(1, true)
Expand Down

0 comments on commit e6eec53

Please sign in to comment.