diff --git a/native/gulpfile.js b/native/gulpfile.js index b18976991e..c48ef7d409 100644 --- a/native/gulpfile.js +++ b/native/gulpfile.js @@ -10,12 +10,19 @@ var Path = require('path'); var fs = require('fs-extra'); gulp.task('make-cocos2d-x', gulpSequence('gen-cocos2d-x', 'upload-cocos2d-x')); -gulp.task('make-prebuilt', gulpSequence('gen-libs', 'collect-prebuilt-mk', 'archive-prebuilt-mk', 'archive-prebuilt', 'upload-prebuilt', 'upload-prebuilt-mk')); -gulp.task('make-simulator', gulpSequence('gen-simulator', 'update-simulator-config', 'update-simulator-dll', 'archive-simulator', 'upload-simulator')); +gulp.task('make-prebuilt', gulpSequence('gen-libs', 'sleep', 'collect-prebuilt-mk', 'archive-prebuilt-mk', 'archive-prebuilt', 'upload-prebuilt', 'upload-prebuilt-mk')); +gulp.task('make-simulator', gulpSequence('gen-simulator', 'update-simulator-config', 'update-simulator-dll', 'archive-simulator', 'upload-simulator', 'sleep')); gulp.task('publish-source', gulpSequence('init', 'make-cocos2d-x')); gulp.task('publish-prebuilt', gulpSequence('init', 'make-simulator', 'make-prebuilt')); +if (process.platform === 'darwin') { + gulp.task('publish', gulpSequence('init', 'make-cocos2d-x', 'make-simulator', 'make-prebuilt')); +} +else { + gulp.task('publish', gulpSequence('publish-prebuilt')); +} + function execSync(cmd, workPath) { var execOptions = { cwd: workPath || '.', @@ -40,23 +47,29 @@ function upload2Ftp(localPath, ftpPath, config, cb) { var ftpClient = new Ftp(); ftpClient.on('error', function(err) { if (err) { - cb(err); + if (cb) { + cb(err); + } + else { + console.warn('Upload errored after destroy: ', ftpPath); + } } }); ftpClient.on('ready', function() { var dirName = Path.dirname(ftpPath); ftpClient.mkdir(dirName, true, function(err) { if (err) { - cb(err); + return cb(err); } - }); - - ftpClient.put(localPath, ftpPath, function(err) { - if (err) { - cb(err); - } - ftpClient.end(); - cb(); + ftpClient.put(localPath, ftpPath, function(err) { + if (err) { + return cb(err); + } + ftpClient.end(); + ftpClient.destroy(); + cb(); + cb = null; + }); }); }); @@ -75,12 +88,7 @@ function uploadZipFile(zipFileName, path, cb) { host: '192.168.52.109', user: process.env.ftpUser, password: process.env.ftpPass - }, function(err) { - if (err) { - throw err; - } - cb(); - }); + }, cb); } function getCurrentBranch() { @@ -151,8 +159,9 @@ gulp.task('gen-simulator', function(cb) { } if (process.platform === 'darwin') { //reset project file to hide code sign information. - ExecSync('git checkout -- ./tools/simulator/frameworks/runtime-src/proj.ios_mac/simulator.xcodeproj'); + execSync('git checkout -- ./tools/simulator/frameworks/runtime-src/proj.ios_mac/simulator.xcodeproj'); } + cb(); }); child.on('error', function() { cb('Generate simulator failed'); @@ -164,6 +173,7 @@ gulp.task('gen-simulator', function(cb) { gulp.task('sign-simulator', function () { if (process.platform === 'darwin') { + execSync('git checkout -- ./tools/simulator/frameworks/runtime-src/proj.ios_mac/simulator.xcodeproj'); execSync('/Applications/Xcode.app/Contents/MacOS/Xcode ./tools/simulator/frameworks/runtime-src/proj.ios_mac/simulator.xcodeproj'); fs.copySync('./tools/simulator/frameworks/runtime-src/proj.ios_mac/simulator.xcodeproj', './simulator.xcodeproj'); } @@ -251,4 +261,9 @@ gulp.task('upload-cocos2d-x', function(cb) { gulp.task('upload-simulator', function(cb) { var zipFileName = 'simulator_' + process.platform + '.zip'; uploadZipFile(zipFileName, '.', cb); -}); \ No newline at end of file +}); + +gulp.task('sleep', function(cb) { + // sleep for a while to avoid network bug + setTimeout(cb, 1000); +});