diff --git a/packages/taro-cli/src/create/init.ts b/packages/taro-cli/src/create/init.ts index fd36fc80d242..b39b85842047 100644 --- a/packages/taro-cli/src/create/init.ts +++ b/packages/taro-cli/src/create/init.ts @@ -162,6 +162,21 @@ export async function createApp ( const templatePath = creater.templatePath(template) const projectPath = path.join(projectDir, projectName) + // default 模板发布 npm 会滤掉 '.' 开头的文件,因此改为 '_' 开头,这里先改回来。 + if (template === 'default') { + const files = await fs.readdir(templatePath) + const renames = files + .map(file => { + const filePath = path.join(templatePath, file) + if (fs.statSync(filePath).isFile() && file.startsWith('_')) { + return fs.rename(filePath, path.join(templatePath, file.replace(/^_/, '.'))) + } + return Promise.resolve() + }) + + await Promise.all(renames) + } + // npm & yarn const version = helper.getPkgVersion() const shouldUseYarn = helper.shouldUseYarn() diff --git a/packages/taro-cli/templates/default/.editorconfig b/packages/taro-cli/templates/default/_editorconfig similarity index 100% rename from packages/taro-cli/templates/default/.editorconfig rename to packages/taro-cli/templates/default/_editorconfig diff --git a/packages/taro-cli/templates/default/.eslintrc b/packages/taro-cli/templates/default/_eslintrc similarity index 100% rename from packages/taro-cli/templates/default/.eslintrc rename to packages/taro-cli/templates/default/_eslintrc diff --git a/packages/taro-cli/templates/default/.gitignore b/packages/taro-cli/templates/default/_gitignore similarity index 100% rename from packages/taro-cli/templates/default/.gitignore rename to packages/taro-cli/templates/default/_gitignore diff --git a/packages/taro-cli/templates/default/.npmrc b/packages/taro-cli/templates/default/_npmrc similarity index 100% rename from packages/taro-cli/templates/default/.npmrc rename to packages/taro-cli/templates/default/_npmrc