File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -234,18 +234,19 @@ api.onCreateComplete(() => {
234
234
235
235
Finally, you need to write the content back to the main file:
236
236
237
- ``` js{11}
237
+ ``` js{2, 11}
238
238
// generator/index.js
239
239
240
240
api.onCreateComplete(() => {
241
+ const { EOL } = require('os')
241
242
const fs = require('fs')
242
243
const contentMain = fs.readFileSync(api.entryFile, { encoding: 'utf-8' })
243
244
const lines = contentMain.split(/\r?\n/g)
244
245
245
246
const renderIndex = lines.findIndex(line => line.match(/render/))
246
- lines[renderIndex] += `\n router,`
247
+ lines[renderIndex] += `${EOL} router,`
247
248
248
- fs.writeFileSync(api.entryFile, contentMain , { encoding: 'utf-8' })
249
+ fs.writeFileSync(api.entryFile, lines.join(EOL) , { encoding: 'utf-8' })
249
250
})
250
251
```
251
252
You can’t perform that action at this time.
0 commit comments