使用run.inDir()设置生成器目标目录不起作用

时间:2019-05-01 14:35:12

标签: typescript mocha chai yeoman-generator

我有一个简单的yeoman生成器,可以生成包含一些文件的目录。 在我的测试中,我使用.inDir(path.join(__ dirname,testDirectoryName))来设置生成器的特定目录以设置结果,但是它将在其根目录(生成器所在的位置)中生成目录和文件。

我也尝试了不使用.inDir()的情况,结果按预期出现在某些临时文件夹中。但这对我们的测试不利。

before(() => {
  return helpers.run(path.join(__dirname, '../generators/app'))
    .inDir(path.join(__dirname, testDirectoryName))
    .withOptions({
      projectPath: projectPath,
      projectName: projectName,
      configPath: configFilePath,
      'skip-install': true
    })
    .withPrompts({moduleName: "Yes"});
});

预期结果:

  • generator-x
    • testDirectoryName
      • 项目名称
        • file1
        • file2
        • file3

结果:

  • generator-x
    • testDirectoryName
    • 项目名称
      • file1
      • file2
      • file3

0 个答案:

没有答案