Skip to content

Commit

Permalink
fix(cli): 修复 windows 创建模板时路径问题,fix #4196
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen-jj committed Aug 19, 2019
1 parent e2328f1 commit ba32828
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/taro-cli/src/create/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function createFiles (

files.forEach(file => {
// fileRePath startsWith '/'
const fileRePath = file.replace(templatePath, '').replace(path.sep, '/')
const fileRePath = file.replace(templatePath, '').replace(new RegExp(`\\${path.sep}`, 'g'), '/')
let externalConfig: any = null

// 跑自定义逻辑,确定是否创建此文件
Expand Down Expand Up @@ -189,11 +189,11 @@ export async function createApp (

if (useNpmrc) {
creater.template(template, '.npmrc', path.join(projectPath, '.npmrc'))
logs.push(`${chalk.green('✔ ')}${chalk.grey(`创建文件: ${projectName}/.npmrc`)}`)
logs.push(`${chalk.green('✔ ')}${chalk.grey(`创建文件: ${projectName}${path.sep}.npmrc`)}`)
}
if (useYarnLock) {
creater.template(template, yarnLockfilePath, path.join(projectPath, 'yarn.lock'))
logs.push(`${chalk.green('✔ ')}${chalk.grey(`创建文件: ${projectName}/yarn.lock`)}`)
logs.push(`${chalk.green('✔ ')}${chalk.grey(`创建文件: ${projectName}${path.sep}yarn.lock`)}`)
}

// 遍历出模板中所有文件
Expand Down

0 comments on commit ba32828

Please sign in to comment.