Skip to content

Commit 8ccea27

Browse files
committed
chore: ensure EOL on generated files
close vuejs#2127
1 parent 7ec466d commit 8ccea27

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/@vue/cli/lib/Generator.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ const reservedConfigTransforms = {
5858
})
5959
}
6060

61+
const ensureEOL = str => {
62+
if (str.charAt(str.length - 1) !== '\n') {
63+
return str + '\n'
64+
}
65+
return str
66+
}
67+
6168
module.exports = class Generator {
6269
constructor (context, {
6370
pkg = {},
@@ -109,7 +116,7 @@ module.exports = class Generator {
109116
await this.resolveFiles()
110117
// set package.json
111118
this.sortPkg()
112-
this.files['package.json'] = JSON.stringify(this.pkg, null, 2)
119+
this.files['package.json'] = JSON.stringify(this.pkg, null, 2) + '\n'
113120
// write/update file tree to disk
114121
await writeFileTree(this.context, this.files, initialFiles)
115122
}
@@ -136,7 +143,7 @@ module.exports = class Generator {
136143
this.context
137144
)
138145
const { content, filename } = res
139-
this.files[filename] = content
146+
this.files[filename] = ensureEOL(content)
140147
delete this.pkg[key]
141148
}
142149
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy