运行生成器时this.fs.move需要权限

时间:2017-12-06 16:58:02

标签: yeoman yeoman-generator

我正在尝试执行以下操作,而不需要在运行生成器时进行手动干预:

  1. 克隆回购
  2. 将其中的子目录移至
  3. 上方的一个级别
  4. 删除原始目录
  5. 任何人都可以建议我在没有提示的情况下运行此生成器的任何步骤吗?

    我想我可能遇到异步问题,this.fs.move在生成器运行后与this.fs.delete同时运行?

    可能与this

    有关
      

    由于异步API更难使用,Yeoman提供了一个同步文件系统API,其中每个文件都被写入内存文件系统,并且只有在Yeoman运行完毕后才会写入磁盘。

    这是我正在使用的代码:

    child_process.exec('git clone --depth 1 ' + aplugin.url + ' build/plugins/' + aplugin.directoryName + '-hassubdir', () => {
      del([
        'build/plugins/' + aplugin.directoryName + '/-hassubdir/readme.md',
        'build/plugins/' + aplugin.directoryName + '/-hassubdir/.git'
      ])
      .then(() => {
        this.fs.move('build/plugins/' + aplugin.directoryName + '-hassubdir/' + aplugin.directoryName, 'build/plugins/' + aplugin.directoryName);
        console.log(chalk.green('moved plugin dir to: build/plugins/' + aplugin.directoryName));
        this.fs.delete('build/plugins/' + aplugin.directoryName + '-hassubdir');
        console.log(chalk.green('deleted: build/plugins/' + aplugin.directoryName + '-hassubdir'));
      })
    });
    

    然后在终端的我的yeoman输出中:

    conflict build/plugins/pluginname-hassubdir/pluginname
    ? Overwrite build/plugins/pluginname-hassubdir/pluginname? overwrite
        force build/plugins/pluginname-hassubdir/pluginname
       create build/plugins/pluginname-hassubdir/pluginname/pluginnamePlugin.php
       create build/plugins/pluginname/pluginnamePlugin.php
       create build/plugins/pluginname-hassubdir/pluginname/resources/icon.svg
       create build/plugins/pluginname/resources/icon.svg
       create build/plugins/pluginname-hassubdir/pluginname/variables/pluginnameVariable.php
       create build/plugins/pluginname/variables/pluginnameVariable.php
       create build/plugins/pluginname-hassubdir/pluginname/resources
       create build/plugins/pluginname-hassubdir/pluginname/variables
     conflict build/plugins/pluginname-hassubdir
    ? Overwrite build/plugins/pluginname-hassubdir? (ynaxH)
    

0 个答案:

没有答案