我正在尝试重命名目标目录中的文件夹。我的
templates
文件夹如下所示:
root/
âââ generators
â âââ app
â âââ templates
â â âââ app
â â âââ widget
â â âââ widget.controller.ts
â â âââ widget.service.ts
â â âââ widget.module.ts
â âââ index.js
âââ .yo-rc.json
我正在尝试重命名
widget
目录(在
destinationPath
)到用户在
prompting
阶段我是这样尝试的:
module.exports = generators.Base.extend({
copyAppTemplate: function () {
this.fs.copyTpl(this.templatePath('**/*'), this.destinationPath('.'), this.props);
this.fs.move(
this.destinationPath('app/widget'),
this.destinationPath('app/' + this.props.widgetName)
);
}
})
呼叫
copyTpl
正确地从
templatePath
到
目标路径
然而,当
fs.move
调用操作时,我收到以下错误消息:
PS C:\Users\username\code\generator-dashboard-widget-test> yo dashboard-widget
? Your widget's name: (generator-dashboard-widget-test)
? Your widget's name: generator-dashboard-widget-test
events.js:154
throw er; // Unhandled 'error' event
^
AssertionError: Trying to copy from a source that does not exist: C:\Users\username\code\generator-dashboard-widget-test\app\widget
at EditionInterface.exports._copySingle (C:\Users\username\code\generator-dashboard-widget\node_modules\mem-fs-editor\lib\actions\copy.js:45:3)
at EditionInterface.exports.copy (C:\Users\username\code\generator-dashboard-widget\node_modules\mem-fs-editor\lib\actions\copy.js:23:17)
at EditionInterface.module.exports [as move] (C:\Users\username\code\generator-dashboard-widget\node_modules\mem-fs-editor\lib\actions\move.js:4:8)
at module.exports.generators.Base.extend.copyAppTemplate (C:\Users\username\code\generator-dashboard-widget\generators\app\index.js:54:17)
at Object.<anonymous> (C:\Users\username\code\generator-dashboard-widget\node_modules\yeoman-generator\lib\base.js:431:23)
at C:\Users\username\code\generator-dashboard-widget\node_modules\run-async\index.js:26:25
at C:\Users\username\code\generator-dashboard-widget\node_modules\run-async\index.js:25:19
at C:\Users\username\code\generator-dashboard-widget\node_modules\yeoman-generator\lib\base.js:432:9
at processImmediate [as _immediateCallback] (timers.js:383:17)
据我所知
Yeoman file system documenation
,虚拟文件系统上的所有操作都是同步的,因此
app/widget
目录应在
mem-fs-editor
实例尝试移动它。
有没有其他方法可以重命名目录?
我在Windows 8.1上使用Yeoman 1.8.4,节点为5.6.0。