This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.runCmd = function(cmd) { | |
return Q.nfcall(exec, cmd); | |
} | |
// 检测代码是否已经ci | |
exports.checkCodeStatus = function() { | |
return this.runCmd('git status') | |
.then(function(stObj) { | |
var stMsg = stObj[0]; | |
if (stMsg.indexOf('git add') !== -1 || stMsg.indexOf('git checkout') !== -1) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const clonedArray = JSON.parse(JSON.stringify(objectArray)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ref: http://stackoverflow.com/questions/5827612/node-js-fs-readdir-recursive-directory-search | |
var fs = require('fs'); | |
var path = require('path'); | |
var walk = function(dir, done) { | |
var results = []; | |
fs.readdir(dir, function(err, list) { | |
if (err) return done(err); | |
var pending = list.length; | |
if (!pending) return done(null, results); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs-extra'); | |
// 1. 使用fs.exists | |
function exists(path) { | |
return new Promise(resolve => { | |
fs.exists(path, resolve); | |
}) | |
} | |
// 2. 使用fs.stat |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 判断图片是否曝光 | |
*/ | |
// 图片离屏幕边缘的GAP值,用于提前曝光图片,优化用户浏览体验 | |
var OFFSET_GAP = 30; | |
var $win = $(window); | |
var $doc = $(document); | |
function isExposured(img) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 加载更多,设计要点: | |
* 1. 使用controller来控制滚动节流,传递controller给用户回调,用户自由控制节流,以及是否终止loadMore行为; | |
* 2. loadMore返回controller,让用户可以停止、启动loadMore,特别适合单页应用时不断启停loadMore; | |
* | |
* @author lihao.ylh@alibaba-inc.com | |
* @date 2015-11-09 11:06 | |
*/ | |
var LOADING_SELECTOR = '#loading'; |