From 40d9db8f9b791a9148931e3b22abd713946aa4a7 Mon Sep 17 00:00:00 2001 From: luckyadam Date: Tue, 23 Feb 2016 15:50:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=A4=8D=E5=88=B6=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E6=97=B6=E5=BD=93=E7=BB=84=E4=BB=B6=E4=B8=8D=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E6=97=B6=E7=BB=99=E4=BA=88=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +++++- lib/build/tasks/clone.js | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0a17938..2c8ecdc 100644 --- a/README.md +++ b/README.md @@ -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 清除缓存,目前缓存包含 **模板文件** 、 **发布时的缓存文件** diff --git a/lib/build/tasks/clone.js b/lib/build/tasks/clone.js index c7e3a44..3c5effa 100644 --- a/lib/build/tasks/clone.js +++ b/lib/build/tasks/clone.js @@ -5,6 +5,7 @@ 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) { @@ -12,7 +13,13 @@ module.exports = function ($, appConf, moduleConf, args) { 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;