Skip to content

fix(plugin api): fix generator dotfile rename for Windows. #2427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/@vue/cli/__tests__/Generator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ fs.ensureDirSync(templateDir)
fs.writeFileSync(path.resolve(templateDir, 'foo.js'), 'foo(<%- options.n %>)')
fs.ensureDirSync(path.resolve(templateDir, 'bar'))
fs.writeFileSync(path.resolve(templateDir, 'bar/bar.js'), 'bar(<%- m %>)')
fs.writeFileSync(path.resolve(templateDir, 'bar/_bar.js'), '.bar(<%- m %>)')
fs.writeFileSync(path.resolve(templateDir, 'entry.js'), `
import foo from 'foo'

Expand Down Expand Up @@ -347,6 +348,7 @@ test('api: render fs directory', async () => {

expect(fs.readFileSync('/foo.js', 'utf-8')).toMatch('foo(1)')
expect(fs.readFileSync('/bar/bar.js', 'utf-8')).toMatch('bar(2)')
expect(fs.readFileSync('/bar/.bar.js', 'utf-8')).toMatch('.bar(2)')
expect(fs.readFileSync('/replace.js', 'utf-8')).toMatch('baz(2)')
expect(fs.readFileSync('/multi-replace.js', 'utf-8')).toMatch('baz(1)\nqux(2)')
expect(fs.readFileSync('/.gitignore', 'utf-8')).toMatch('foo')
Expand Down
4 changes: 2 additions & 2 deletions packages/@vue/cli/lib/GeneratorAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class GeneratorAPI {
const globby = require('globby')
const _files = await globby(['**/*'], { cwd: source })
for (const rawPath of _files) {
const targetPath = rawPath.split(path.sep).map(filename => {
const targetPath = rawPath.split('/').map(filename => {
// dotfiles are ignored when published to npm, therefore in templates
// we need to use underscore instead (e.g. "_gitignore")
if (filename.charAt(0) === '_' && filename.charAt(1) !== '_') {
Expand All @@ -179,7 +179,7 @@ class GeneratorAPI {
return `${filename.slice(1)}`
}
return filename
}).join(path.sep)
}).join('/')
const sourcePath = path.resolve(source, rawPath)
const content = renderFile(sourcePath, data, ejsOptions)
// only set file if it's not all whitespace, or is a Buffer (binary files)
Expand Down