Я пытаюсь переименовать папку в каталоге назначения. Структура каталогов внутри моей templates
папки выглядит следующим образом:Переименовать вновь созданный каталог с помощью Yeoman (mem-fs-editor)
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
в destinationPath
. Однако, когда операция 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
экземпляр пытается переместить его.
Есть ли другой способ переименовать каталог?
Я использую Yeoman 1.8.4 на Windows 8.1 с узлом 5.6.0.