Skip to content

Commit

Permalink
fix: avoid dotfiles not being published to npm
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 25, 2018
1 parent b913047 commit 2e3fe07
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/@vue/cli/lib/GeneratorAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,18 @@ module.exports = class GeneratorAPI {
filter: file => path.basename(file.path) !== '.DS_Store'
})
for (const file of _files) {
const relativePath = path.relative(fileDir, file.path)
let filename = path.basename(file.path)
// dotfiles are ignored when published to npm, therefore in templates
// we need to use underscore instead (e.g. "_gitignore")
if (filename.charAt(0) === '_') {
filename = `.${filename.slice(1)}`
}
const normalizedPath = path.join(path.dirname(file.path), filename)
const targetPath = path.relative(fileDir, normalizedPath)
const content = renderFile(file.path, data, ejsOptions)
// only set file if it's not all whitespace, or is a Buffer (binary files)
if (Buffer.isBuffer(content) || /[^\s]/.test(content)) {
files[relativePath] = content
files[targetPath] = content
}
}
})
Expand Down

0 comments on commit 2e3fe07

Please sign in to comment.