fis-command-release
Advanced tools
Comparing version 0.11.3 to 0.11.4
@@ -27,2 +27,3 @@ /* | ||
} | ||
return '127.0.0.1'; | ||
@@ -34,2 +35,3 @@ })(); | ||
from = from.replace(/\/$/, ''); | ||
if(subOnly){ | ||
@@ -46,19 +48,21 @@ return path.substring(from.length); | ||
} | ||
return path; | ||
} | ||
function prepareDeploy(dest, file, callback){ | ||
if(file.release){ | ||
function prepareDeploy(dest, file, callback) { | ||
if(file.release) { | ||
var release = replaceFrom(file.release, dest.from, dest.subOnly); | ||
var content = file.getContent(); | ||
var charset = file.charset; | ||
if(file.isText() && content.length){ | ||
if(dest.replace && dest.replace.from){ | ||
if(file.isText() && content.length) { | ||
if(dest.replace && dest.replace.from) { | ||
var reg = dest.replace.from; | ||
if(typeof reg === 'string'){ | ||
if(typeof reg === 'string') { | ||
reg = new RegExp(fis.util.escapeReg(reg), 'g'); | ||
} else if(!(reg instanceof RegExp)){ | ||
} else if(!(reg instanceof RegExp)) { | ||
fis.log.error('invalid deploy.replace.from [' + reg + ']'); | ||
} | ||
content = content.replace(reg, dest.replace.to); | ||
@@ -75,2 +79,3 @@ } | ||
} | ||
return m; | ||
@@ -88,10 +93,20 @@ }); | ||
file.setContent(content); | ||
} | ||
if(file.useHash && dest.opt.md5 > 0){ | ||
if (!processors[dest._type]){ | ||
fis.log.error('invalid deploy plugin [' + dest._type + ']'); | ||
} | ||
if(file.useHash && dest.opt.md5 > 0) { | ||
if (dest.opt.md5 > 1) { | ||
//保留不带md5的文件,release | ||
callback && callback(processors[dest._type], dest, release, file, content, settings[dest._name]); | ||
} | ||
release = file.getHashRelease(release); | ||
} | ||
if (!processors[dest._type]){ | ||
fis.log.error('invalid deploy plugin [' + dest._type + ']'); | ||
} | ||
callback && callback(processors[dest._type], dest, release, file, content, settings[dest._name]); | ||
} else { | ||
@@ -107,2 +122,3 @@ fis.log.error('unreleasable file [' + file.realpath + ']'); | ||
} | ||
return str.replace(/\/$/, '') + '/'; | ||
@@ -122,13 +138,13 @@ } | ||
function doTask(tasks, done){ | ||
function doTask(tasks, done) { | ||
var asyncTasks = []; | ||
tasks.forEach(function(task){ | ||
asyncTasks.push(function(cb){ | ||
prepareDeploy(task.dest, task.file, function(processor, dest, release, file, content, settings){ | ||
processor({to: dest.to, release: release}, file, content, dest, function(){ | ||
tasks.forEach(function(task) { | ||
asyncTasks.push(function(cb) { | ||
prepareDeploy(task.dest, task.file, function(processor, dest, release, file, content, settings) { | ||
processor({to: dest.to, release: release}, file, content, dest, function() { | ||
//https://github.com/caolan/async/issues/75 | ||
//call async.parallelLimit with a sync function might cause Maximum call stack size exceeded | ||
setTimeout(function(){ | ||
setTimeout(function() { | ||
cb && cb(); | ||
},0); | ||
}, 0); | ||
}); | ||
@@ -138,2 +154,3 @@ }); | ||
}); | ||
async.parallelLimit(asyncTasks, exports.MAX_TASK_SIZE, done); | ||
@@ -144,7 +161,7 @@ } | ||
var asyncTasks = []; | ||
fis.util.map(packTasks, function(name, tasks){ | ||
fis.util.map(packTasks, function(name, tasks) { | ||
var files = []; | ||
var taskSettings, taskProcessor; | ||
tasks.forEach(function(task){ | ||
prepareDeploy(task.dest, task.file, function(processor, dest, release, file, content, settings){ | ||
tasks.forEach(function(task) { | ||
prepareDeploy(task.dest, task.file, function(processor, dest, release, file, content, settings) { | ||
taskSettings = settings; | ||
@@ -162,10 +179,14 @@ taskProcessor = processor; | ||
}); | ||
if (taskProcessor){ | ||
asyncTasks.push(function(cb){ | ||
asyncTasks.push(function(cb) { | ||
taskProcessor(files, taskSettings, cb); | ||
}); | ||
}else{ | ||
} else { | ||
fis.log.warning('invalid pack deploy content: empty') | ||
} | ||
}); | ||
async.parallelLimit(asyncTasks, exports.MAX_TASK_SIZE, done); | ||
@@ -189,6 +210,6 @@ } | ||
var tasks = flaten ? [] : {}; | ||
fis.util.map(files, function(subpath, file){ | ||
fis.util.map(depolyConfs, function(name, depolyConf){ | ||
fis.util.map(files, function(subpath, file) { | ||
fis.util.map(depolyConfs, function(name, depolyConf) { | ||
var target = flaten? tasks : (tasks[name] = tasks[name] || []); | ||
depolyConf.forEach(function(d){ | ||
depolyConf.forEach(function(d) { | ||
if( | ||
@@ -198,8 +219,11 @@ file.release && | ||
fis.util.filter(file.release, d.include, d.exclude) | ||
){ | ||
) { | ||
target.push({dest : d, file : file }); | ||
} | ||
}); | ||
}); | ||
}); | ||
return tasks; | ||
@@ -242,24 +266,32 @@ } | ||
}); | ||
var deployConfs = {}; | ||
var packDeployConfs = {}; | ||
//choose deploy config by deploy option | ||
opt.dest.split(/,/g).forEach(function(destName){ | ||
if (!destName){ | ||
if (!destName) { | ||
return false; | ||
} | ||
var dest = settings[destName] || {}; | ||
if (!dest._type){ | ||
dest._type = DEFAULT_DEPLOY_KEY; | ||
} | ||
var target; | ||
if (dest._fullpack){ | ||
if (dest._fullpack) { | ||
target = packDeployConfs[destName] = packDeployConfs[destName] || []; | ||
}else{ | ||
} else { | ||
target = deployConfs[destName] = deployConfs[destName] || []; | ||
} | ||
if(fis.util.is(dest, 'Array')){ | ||
dest.forEach(function(item){ | ||
if(fis.util.is(dest, 'Array')) { | ||
dest.forEach(function(item) { | ||
target.push(factory(item, opt, root)); | ||
}); | ||
}else { | ||
} else { | ||
//only used when deploy type is default or none | ||
@@ -271,3 +303,3 @@ if(!dest.to && dest._type == DEFAULT_DEPLOY_KEY){ | ||
fis.util.isAbsolute(destName) //absolute path | ||
){ | ||
) { | ||
dest.to = destName; | ||
@@ -279,2 +311,3 @@ dest._type = DEFAULT_DEPLOY_KEY; | ||
} | ||
target.push(factory(dest, opt, root)); | ||
@@ -281,0 +314,0 @@ } |
@@ -0,0 +0,0 @@ Copyright (C) 2013 baidu.com |
{ | ||
"name": "fis-command-release", | ||
"description": "fis release command.", | ||
"version": "0.11.3", | ||
"version": "0.11.4", | ||
"author": "FIS Team <fis@baidu.com>", | ||
@@ -23,3 +23,3 @@ "homepage": "http://fis.baidu.com/", | ||
"async": "0.9.0", | ||
"chokidar": "0.8.4", | ||
"chokidar": "0.12.5", | ||
"livereload-server-spec": "0.2.3" | ||
@@ -26,0 +26,0 @@ }, |
@@ -0,0 +0,0 @@ # fis-command-release |
@@ -17,9 +17,29 @@ /* | ||
var ignoredReg = /[\/\\](?:output\b[^\/\\]*([\/\\]|$)|\.|fis-conf\.js$)/i; | ||
function listener(path){ | ||
if(safePathReg.test(path)){ | ||
clearTimeout(timer); | ||
timer = setTimeout(function(){ | ||
release(opt); | ||
}, 500); | ||
} | ||
opt.srcCache = fis.project.getSource(); | ||
function listener(type){ | ||
return function (path) { | ||
if(safePathReg.test(path)){ | ||
var file = fis.file.wrap(path); | ||
if (type == 'add' || type == 'change') { | ||
if (!opt.srcCache[file.subpath]) { | ||
var file = fis.file(path); | ||
opt.srcCache[file.subpath] = file; | ||
} | ||
} else if (type == 'unlink') { | ||
if (opt.srcCache[file.subpath]) { | ||
delete opt.srcCache[file.subpath]; | ||
} | ||
} else if (type == 'unlinkDir') { | ||
fis.util.map(opt.srcCache, function (subpath, file) { | ||
if (file.realpath.indexOf(path) !== -1) { | ||
delete opt.srcCache[subpath]; | ||
} | ||
}); | ||
} | ||
clearTimeout(timer); | ||
timer = setTimeout(function(){ | ||
release(opt); | ||
}, 500); | ||
} | ||
}; | ||
} | ||
@@ -51,5 +71,6 @@ | ||
}) | ||
.on('add', listener) | ||
.on('change', listener) | ||
.on('unlink', listener) | ||
.on('add', listener('add')) | ||
.on('change', listener('change')) | ||
.on('unlink', listener('unlink')) | ||
.on('unlinkDir', listener('unlinkDir')) | ||
.on('error', function(err){ | ||
@@ -315,2 +336,2 @@ //fis.log.error(err); | ||
}); | ||
}; | ||
}; |
@@ -0,0 +0,0 @@ (function() { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1552
58892
+ Addedasync-each@0.1.6(transitive)
+ Addedchokidar@0.12.5(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedfsevents@0.3.8(transitive)
+ Addedgraceful-fs@2.0.3(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedlru-cache@2.7.3(transitive)
+ Addedminimatch@0.2.14(transitive)
+ Addednan@2.22.0(transitive)
+ Addedreadable-stream@1.0.34(transitive)
+ Addedreaddirp@1.3.0(transitive)
+ Addedsigmund@1.0.1(transitive)
+ Addedstring_decoder@0.10.31(transitive)
- Removedchokidar@0.8.4(transitive)
- Removedrecursive-readdir@0.0.2(transitive)
Updatedchokidar@0.12.5