Revert "Fix new-error command" (#45221)
This commit is contained in:
parent
a6dcbfedd0
commit
5ca8bd943a
1 changed files with 11 additions and 11 deletions
22
plopfile.js
22
plopfile.js
|
@ -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',
|
||||
|
@ -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',
|
||||
},
|
||||
|
@ -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
|
||||
)}`,
|
||||
]
|
||||
},
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue