fis-command-release
Advanced tools
Comparing version 0.8.1 to 0.8.2
@@ -8,9 +8,9 @@ /* | ||
function upload(receiver, to, release, file){ | ||
function upload(receiver, to, release, content, subpath){ | ||
fis.util.upload( | ||
//url, request options, post data, file | ||
receiver, null, { to : to + release }, file, | ||
receiver, null, { to : to + release }, content, subpath, | ||
function(err, res){ | ||
if(err || res != '0'){ | ||
fis.log.error('upload file [' + file.subpath + '] to [' + to + | ||
fis.log.error('upload file [' + subpath + '] to [' + to + | ||
'] by receiver [' + receiver + '] error [' + (err || res) + ']'); | ||
@@ -22,3 +22,3 @@ } else { | ||
time.grey + ' ' + | ||
file.subpath.replace(/^\//, '') + | ||
subpath.replace(/^\//, '') + | ||
' >> '.yellow.bold + | ||
@@ -33,2 +33,29 @@ to + release + | ||
function deliver(output, md5, release, content, file){ | ||
if(!release){ | ||
fis.log.error('unable to get release path of file[' | ||
+ file.realpath | ||
+ ']: Maybe this file is neither in current project or releasable'); | ||
} | ||
if(fis.util.exists(output) && !fis.util.isDir(output)){ | ||
fis.log.error('unable to deliver file[' | ||
+ file.realpath + '] to dir[' | ||
+ output + ']: invalid output dir.'); | ||
} | ||
var target; | ||
if(md5 == 0 || !file.useHash){ | ||
target = fis.util(output, release); | ||
fis.util.write(target, content); | ||
} else if(md5 == 1){ | ||
target = fis.util(output, file.getHashRelease(release)); | ||
fis.util.write(target, content); | ||
} else { | ||
target = fis.util(output, release); | ||
fis.util.write(target, content); | ||
target = fis.util(output, file.getHashRelease(release)); | ||
fis.util.write(target, content); | ||
} | ||
} | ||
function replaceFrom(path, from){ | ||
@@ -51,11 +78,16 @@ if(path.indexOf(from) === 0){ | ||
var release = replaceFrom(file.release, dest.from); | ||
var content = file.getContent(); | ||
var charset = file.charset; | ||
if(file.isText() && content.length && charset !== 'utf8' && charset !== 'utf-8'){ | ||
content = fis.util.toEncoding(content, charset); | ||
} | ||
if(dest.receiver){ | ||
if(!file.useHash || dest.md5 != 1){ | ||
upload(dest.receiver, dest.to, release, file); | ||
upload(dest.receiver, dest.to, release, content, file.subpath); | ||
} | ||
if(file.useHash && dest.md5 > 0){ | ||
upload(dest.receiver, dest.to, file.getHashRelease(release), file); | ||
upload(dest.receiver, dest.to, file.getHashRelease(release), content, file.subpath); | ||
} | ||
} else { | ||
file.deliver(dest.to, dest.md5, release); | ||
deliver(dest.to, dest.md5, release, content, file); | ||
} | ||
@@ -62,0 +94,0 @@ } else { |
{ | ||
"name" : "fis-command-release", | ||
"description" : "fis release command.", | ||
"version" : "0.8.1", | ||
"version" : "0.8.2", | ||
"author" : "FIS Team <fis@baidu.com>", | ||
@@ -6,0 +6,0 @@ "homepage" : "http://fis.baidu.com/", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
50970
1365
0