We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b993030 commit ecbccc6Copy full SHA for ecbccc6
docs/dev-guide/plugin-dev.md
@@ -234,18 +234,19 @@ api.onCreateComplete(() => {
234
235
Finally, you need to write the content back to the main file:
236
237
-```js{11}
+```js{2,11}
238
// generator/index.js
239
240
api.onCreateComplete(() => {
241
+ const { EOL } = require('os')
242
const fs = require('fs')
243
const contentMain = fs.readFileSync(api.entryFile, { encoding: 'utf-8' })
244
const lines = contentMain.split(/\r?\n/g)
245
246
const renderIndex = lines.findIndex(line => line.match(/render/))
- lines[renderIndex] += `\n router,`
247
+ lines[renderIndex] += `${EOL} router,`
248
- fs.writeFileSync(api.entryFile, contentMain, { encoding: 'utf-8' })
249
+ fs.writeFileSync(api.entryFile, lines.join(EOL), { encoding: 'utf-8' })
250
})
251
```
252
0 commit comments