Skip to content

Commit

Permalink
fix:复制组件时当组件不存在时给予提示
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Feb 23, 2016
1 parent be00e14 commit 40d9db8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -655,14 +655,18 @@ $ ath pu -m [模块名]
携带参数``--remote``指定要发布的机器,机器名和 **app-conf.js** 中配置的机器名一致
使用``ath pu -h`` 查看帮助。
### athena clone
进入到某一模块下,通过``athena clone`` 命令可以复制另一个模块的**widget**到当前模块。
```
$ athena clone --from [来源模块] --widget [widget名字]
$ athena clone [组件名字] --from [来源模块] --to [目标模块,若是当前模块可省略]
```
使用``ath clone -h`` 查看帮助。
### athena clear
清除缓存,目前缓存包含 **模板文件** 、 **发布时的缓存文件**
Expand Down
9 changes: 8 additions & 1 deletion lib/build/tasks/clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@ module.exports = function ($, appConf, moduleConf, args) {
return new Promise(function (resolve, reject) {
var path = require('path');
var vfs = require('vinyl-fs');
var Util = require('../../util');

// 拷贝一个widget
if (!widget) {
$.util.log($.util.colors.red('请输入widget来源和widget名称'));
reject();
return;
}
vfs.src(appPath + '/' + source + '/widget/' + widget + '/**')
var sourceWidgetPath = path.join(appPath, source, 'widget', widget);
if (!Util.existsSync(sourceWidgetPath)) {
$.util.log($.util.colors.red('widget ' + widget +' 不存在!'));
reject();
return;
}
vfs.src(path.join(sourceWidgetPath, '**'))
.pipe($.rename(function (path) {
if (path.basename !== 'images' && path.dirname !== 'images' && path.basename !== '') {
path.basename = source + '_' + path.basename;
Expand Down

0 comments on commit 40d9db8

Please sign in to comment.