Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various bug fixes and code issues #2385

Merged
merged 4 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading