Yeoman - 如何在生成器中提取压缩文件?

时间:2016-08-31 10:34:20

标签: yeoman yeoman-generator

我想构建一个需要解压缩文件的Yeoman生成器。

documentation开始,这个过程似乎是使用this.registerTransformStream(...)完成的。它说它接受任何gulp插件,所以我尝试gulp-unziplink

这是我的代码:

// index.js
...
writing: function() {
  var source = this.templatePath('zip'); // the folder where the zipped file is
  var destination = this.destinationRoot();

  this.fs.copy(source, destination);
  this.registerTransformStream(unzip() );
}
...

结果看起来很有希望,首先它显示了所有文件列表然后我得到Error: write after end错误。

这里是转储:

   create license.txt
   create readme.html
   create config.php
   ...
   ...
events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: write after end
    at writeAfterEnd (C:\Users\myname\Documents\project\generator-test\node_modules\gulp-unzip\node_modules\readable-stream\lib\_stream_writable.js:144:12)
    at Transform.Writable.write (C:\Users\myname\Documents\project\generator-test\node_modules\gulp-unzip\node_modules\readable-stream\lib\_stream_writable.js:192:5)
    at DestroyableTransform.ondata (C:\Users\myname\Documents\project\generator-test\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:531:20)
    at emitOne (events.js:77:13)
    at DestroyableTransform.emit (events.js:169:7)
    at readableAddChunk (C:\Users\myname\Documents\project\generator-test\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:198:18)
    at DestroyableTransform.Readable.push (C:\Users\myname\Documents\project\generator-test\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:157:10)
    at DestroyableTransform.Transform.push (C:\Users\myname\Documents\project\generator-test\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:123:32)
    at DestroyableTransform._transform (C:\Users\myname\Documents\project\generator-test\node_modules\mem-fs-editor\lib\actions\commit.js:34:12)
    at DestroyableTransform.Transform._read (C:\Users\myname\Documents\project\generator-test\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:159:10)

此后,目标文件夹为空。似乎流正在尝试编写解压缩文件但失败了。

之前有人解决了这个问题吗?或者只使用内置的 fs

替代方式

非常感谢

0 个答案:

没有答案