Comparing version 0.0.15 to 0.0.16
@@ -16,3 +16,3 @@ function Deal(str) { | ||
var src = this._src; | ||
return src.slice(0, point) + newStr + src.slice(point + str.length); | ||
return src.slice(0, point) + src.slice(point).replace(str, newStr); | ||
} | ||
@@ -37,5 +37,5 @@ }; | ||
} | ||
v.replace(/\);?/gi, function (k, j) { | ||
v.replace(/\)/gi, function (k, j) { | ||
var l = left.pop(); | ||
if(left.length === 0 && l !== 'undefined') { | ||
if(left.length === 0 && typeof l !== 'undefined') { | ||
idxs.push([l + point, start + j + k.length + point]); | ||
@@ -74,3 +74,3 @@ } | ||
end = idxs[0] && idxs[0][1]; | ||
statement = str.slice(ch - 1, end); | ||
statement = str.slice(ch - 1, end + 1); | ||
@@ -101,3 +101,3 @@ return end ? deal(str).update(ch - 1, statement, '/*' + statement + '*/') : false; | ||
end = idxs[0] && idxs[0][1]; | ||
return end ? deal(str).insert(end - 1, ', 10') : false; | ||
return end ? deal(str).update(end - 1, ')', ', 10)') : false; | ||
}, | ||
@@ -104,0 +104,0 @@ // 添加转义 |
@@ -48,20 +48,29 @@ #!/usr/bin/env node | ||
var report = function () { | ||
puts('---------------------------------------'); | ||
puts('-- All errors: ' + counts_all + ', Fixed: ' + fixeds.length + ', Unfixed: ' + unfixs.length + '\n'); | ||
var outputs = []; | ||
if (fixeds.length < 10) { | ||
fixeds.forEach(function(unfix) { | ||
puts('-- [File: ' + unfix.file.replace(root, '') + ']'); | ||
puts(' [Line: ' + unfix.line + ', Character: ' + unfix.character + ']'); | ||
puts('\tReason: ' + unfix.reason); | ||
if (fixeds.length > 0) { | ||
outputs.push('----------The Fixed List---------\n'); | ||
fixeds.forEach(function(fixed) { | ||
outputs.push('oo [File: ' + fixed.file.replace(root, '') + ']'); | ||
outputs.push(' [Line: ' + fixed.line + ', Character: ' + fixed.character + ']'); | ||
outputs.push('\tReason: ' + fixed.reason); | ||
}); | ||
puts('\n---------\n'); | ||
outputs.push('\n---------------End---------------'); | ||
} | ||
unfixs.forEach(function(unfix) { | ||
puts('-- [File: ' + unfix.file.replace(root, '') + ']'); | ||
puts(' [Line: ' + unfix.line + ', Character: ' + unfix.character + ']'); | ||
puts('\tReason: ' + unfix.reason); | ||
}); | ||
puts('---------------------------------------'); | ||
if (unfixs.length > 0) { | ||
outputs.push('\n---------The UnFixed List--------\n'); | ||
unfixs.forEach(function(unfix) { | ||
outputs.push('xx [File: ' + unfix.file.replace(root, '') + ']'); | ||
outputs.push(' [Line: ' + unfix.line + ', Character: ' + unfix.character + ']'); | ||
outputs.push('\tReason: ' + unfix.reason); | ||
}); | ||
outputs.push('\n---------------End---------------'); | ||
} | ||
outputs.push('\n-- All errors: ' + counts_all + ', Fixed: ' + fixeds.length + ', Unfixed: ' + unfixs.length + '\n'); | ||
puts(outputs.join('\n')); | ||
fs.writeFileSync(root + '/jsfix-report.txt', outputs.join('\n'), 'utf-8'); | ||
puts('\nMore info on [' + root + '/jsfix-report.txt]'); | ||
}; | ||
@@ -133,3 +142,3 @@ | ||
file = file.replace(/.seed$/, function (k) { | ||
var stat = fs.statSync(path + '\\' + file), | ||
var stat = fs.statSync(path + '/' + file), | ||
ret = k; | ||
@@ -146,3 +155,3 @@ | ||
if (hasReplace) { | ||
filter[path + '\\' + file] = true; | ||
filter[path + '/' + file] = true; | ||
} | ||
@@ -152,4 +161,4 @@ }); | ||
files.forEach(function(file) { | ||
if (!filter[file] && !filter[path + '\\' + file]) { | ||
doFix(path + '\\' + file); | ||
if (!filter[file] && !filter[path + '/' + file]) { | ||
doFix(path + '/' + file); | ||
} | ||
@@ -156,0 +165,0 @@ }); |
@@ -8,3 +8,3 @@ { | ||
"description": "javascript fix base on jshint", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"main": "./lib/run.js", | ||
@@ -11,0 +11,0 @@ "bin": { |
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
177840
4483