2016-11-26 113 views
1

我正在處理這個Yeoman項目,並且正在將一些文件從模板複製到我的新應用程序目錄。在Yeoman中複製除一個子文件夾之外的文件夾

這條線做的工作還有:

this.fs.copyTpl(this.templatePath(''), 
    this.destinationPath(this.project_name_slugified+'/')); 

一切來源於模板文件夾,並進入到項目的根文件夾。

但是,當有人添加標記「--NR」我要排除已複製一個子文件夾。所以yo my-gen my_app_name --rf應該複製一切,除非這個子文件夾。

我試過!-glob符號,但它不工作。我不喜歡的東西作爲第一個參數:

[this.templatePath('**'),this.templatePath('!subfolder/subfolder_to_be_excluded')] 

所以第二個參數設置,以排除子文件夾是沒有必要的

我也試着刪除(delete法),但似乎該文件是不可用立即。

反正它不工作。有任何想法嗎? Promisifying the copyTpl會起作用嗎?

回答

2

通過調用this.templatePath('!subfolder/subfolder_to_be_excluded'),你最終會產生一個破碎的路徑:/absolute/path/!subfolder/etc

使用它沒有給出this.templatePath你不需要的絕對路徑應用的篩選。

this.fs.copyTpl(
    [ 
     this.templatePath('**'), 
     '!subfolder/subfolder_to_be_excluded' 
    ], 
    this.destinationPath(this.project_name_slugified + '/'), 
    templateContext 
); 
相關問題