Skip to content

Commit eaacafe

Browse files
committed
更新example
1 parent 7b78f60 commit eaacafe

File tree

4 files changed

+50
-53
lines changed

4 files changed

+50
-53
lines changed

app.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@
189189
<input type="text" name="ftp-user" placeholder="用户名" value="">
190190
</div>
191191
<div class="ui-text ui-text_short">
192-
<input type="password" name="ftp-pass" placeholder="密码" value="">
192+
<input type="text" name="ftp-pass" placeholder="密码" value="">
193193
</div>
194194
<div class="ui-text ui-text_short">
195195
<input type="text" name="ftp-port" placeholder="端口" value="">

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"gulp-tmtsprite": "^0.0.22",
6868
"gulp-uglify": "^1.5.3",
6969
"gulp-useref": "^3.1.2",
70-
"gulp-util": "^3.0.7",
70+
"gulp-util": "^3.0.8",
7171
"gulp-webp": "^2.3.0",
7272
"gulp-zip": "^3.2.0",
7373
"imagemin-pngquant": "^4.2.2",

src/_tasks/ftp.js

Lines changed: 48 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,70 +6,67 @@ const gulp = require('gulp');
66
const _ = require('lodash');
77
const del = require('del');
88
const ftp = require('gulp-ftp');
9+
const gutil = require('gulp-util');
910
const Common = require(path.join(__dirname, '../common'));
1011

1112
module.exports = function (projectPath, log, callback) {
1213

13-
let projectConfigPath = path.join(projectPath, 'weflow.config.json');
14-
let config = null;
14+
let distDir = path.join(projectPath, './dist');
1515

16-
if (Common.fileExist(projectConfigPath)) {
17-
config = Common.requireUncached(projectConfigPath);
18-
} else {
19-
config = Common.requireUncached(path.join(__dirname, '../../weflow.config.json'));
20-
}
16+
let projectConfigPath = path.join(projectPath, 'weflow.config.json');
17+
let config = null;
2118

22-
let configFTP = config.ftp;
19+
if (Common.fileExist(projectConfigPath)) {
20+
config = Common.requireUncached(projectConfigPath);
21+
} else {
22+
config = Common.requireUncached(path.join(__dirname, '../../weflow.config.json'));
23+
}
2324

24-
if (configFTP.host === '' || configFTP.pass === '' || configFTP.user === '') {
25-
callback('ftp config');
26-
return;
27-
}
25+
let configFTP = config.ftp;
2826

29-
let projectName = path.basename(projectPath);
27+
if (configFTP.host === '' || configFTP.pass === '' || configFTP.user === '') {
28+
callback('ftp config');
29+
return;
30+
}
3031

31-
//清除目标目录
32-
function delDist(cb) {
33-
del(path.join(projectPath, './dist'), {force: true}).then(function () {
34-
cb && cb();
35-
})
36-
}
32+
let projectName = path.basename(projectPath);
33+
34+
//清除目标目录
35+
function delDist(cb) {
36+
del(path.join(projectPath, './dist'), {force: true}).then(function () {
37+
cb && cb();
38+
})
39+
}
3740

38-
function remoteFtp(cb) {
39-
let remotePath = config['ftp']['remotePath'] || "";
40-
let ftpConfig = _.extend(config['ftp'], {
41-
remotePath: path.join(remotePath, projectName)
42-
});
43-
let distPath = config['ftp']['includeHtml'] ? path.join(projectPath, './dist/**/*') : [path.join(projectPath, './dist/**/*'), path.join(projectPath, '!./dist/html/**/*.html')];
41+
function remoteFtp(cb) {
42+
let remotePath = config['ftp']['remotePath'] || "";
43+
let ftpConfig = _.extend(config['ftp'], {
44+
remotePath: path.join(remotePath, projectName)
45+
});
46+
let distPath = config['ftp']['includeHtml'] ? path.join(projectPath, './dist/**/*') : [path.join(projectPath, './dist/**/*'), path.join(projectPath, '!./dist/html/**/*.html')];
4447

45-
console.log(ftpConfig)
46-
console.log(distPath);
48+
gulp.src(distPath)
49+
.pipe(ftp(ftpConfig))
50+
.pipe(gutil.noop())
51+
.pipe(gulp.dest(distDir))
52+
.on('end', function () {
53+
console.log('ftp success.');
54+
log('ftp success.');
55+
cb && cb();
56+
})
57+
}
4758

48-
gulp.src(distPath)
49-
.pipe(ftp(ftpConfig))
50-
.on('finish', function(){
51-
console.log('sftp success.');
52-
log('sftp success.');
53-
cb && cb();
54-
})
55-
.on('end', function () {
56-
console.log('ftp success.');
57-
log('ftp success.');
58-
cb && cb();
59-
});
59+
async.series([
60+
function (next) {
61+
remoteFtp(next);
62+
}
63+
], function (err) {
64+
if (err) {
65+
throw new Error(err);
6066
}
6167

62-
async.series([
63-
function (next) {
64-
remoteFtp(next);
65-
}
66-
], function (err) {
67-
if (err) {
68-
throw new Error(err);
69-
}
70-
71-
delDist();
68+
delDist();
7269

73-
callback && callback();
74-
});
70+
callback && callback();
71+
});
7572
};

templates/example.zip

70.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)