Skip to content

Commit

Permalink
Revert "Fix new-error command" (#45221)
Browse files Browse the repository at this point in the history
  • Loading branch information
jankaifer committed Jan 25, 2023
1 parent a6dcbfe commit 5ca8bd9
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions plopfile.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module.exports = function (plop) {
function getFileName(str) {
return str.toLowerCase().replace(/ /g, '-')
}
const toFileName = (str) => str.toLowerCase().replace(/ /g, '-')
plop.setHelper('toFileName', toFileName)

plop.setGenerator('test', {
description: 'Create a new test',
Expand Down Expand Up @@ -57,7 +56,7 @@ module.exports = function (plop) {
description: 'Create a new error document',
prompts: [
{
name: 'urlPath',
name: 'name',
type: 'input',
message: 'Url path with dashes. E.g. circular-structure',
},
Expand All @@ -77,27 +76,28 @@ module.exports = function (plop) {
message: 'What are the possible ways to fix it?',
},
],
actions: function (data) {
const fileName = getFileName(data.urlPath)
actions: function ({ name }) {
return [
{
type: 'add',
path: `errors/${fileName}.md`,
path: `errors/{{ toFileName name }}.md`,
templateFile: `errors/template.txt`,
},
{
type: 'modify',
path: 'errors/manifest.json',
transform(fileContents, data) {
transform(fileContents) {
const manifestData = JSON.parse(fileContents)
manifestData.routes[0].routes.push({
title: fileName,
path: `/errors/${fileName}.md`,
title: toFileName(name),
path: `/errors/${toFileName(name)}.md`,
})
return JSON.stringify(manifestData, null, 2)
},
},
`Url for the error: https://nextjs.org/docs/messages/${fileName}`,
`Url for the error: https://nextjs.org/docs/messages/${toFileName(
name
)}`,
]
},
})
Expand Down

0 comments on commit 5ca8bd9

Please sign in to comment.