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(() => {
234234
235235Finally, you need to write the content back to the main file:
236236
237- ``` js{11}
237+ ``` js{2, 11}
238238// generator/index.js
239239
240240api.onCreateComplete(() => {
241+ const { EOL } = require('os')
241242 const fs = require('fs')
242243 const contentMain = fs.readFileSync(api.entryFile, { encoding: 'utf-8' })
243244 const lines = contentMain.split(/\r?\n/g)
244245
245246 const renderIndex = lines.findIndex(line => line.match(/render/))
246- lines[renderIndex] += `\n router,`
247+ lines[renderIndex] += `${EOL} router,`
247248
248- fs.writeFileSync(api.entryFile, contentMain , { encoding: 'utf-8' })
249+ fs.writeFileSync(api.entryFile, lines.join(EOL) , { encoding: 'utf-8' })
249250})
250251```
251252
You can’t perform that action at this time.
0 commit comments