You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2018/05/04 02:07:11 UTC

[incubator-echarts] branch master updated: tweak.

This is an automated email from the ASF dual-hosted git repository.

sushuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git


The following commit(s) were added to refs/heads/master by this push:
     new 1c294e6  tweak.
1c294e6 is described below

commit 1c294e6ebecb42e06592a99b68a83b111eaf325d
Author: sushuang <su...@gmail.com>
AuthorDate: Fri May 4 10:06:58 2018 +0800

    tweak.
---
 .rat-excludes      |  8 ++++----
 build/addHeader.js | 19 +++++++++++++++----
 build/preamble.js  | 16 +++++++++++++---
 build/rat.sh       |  2 +-
 4 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/.rat-excludes b/.rat-excludes
index ddfebe3..435b9b4 100644
--- a/.rat-excludes
+++ b/.rat-excludes
@@ -20,10 +20,10 @@ map/js
 map/json
 test/ut/lib
 test/data$
-test/lib/esl\.js$
-test/lib/perlin\.js$
-test/lib/countup\.js$
-jquery
+test/lib/esl\.js
+test/lib/perlin\.js
+test/lib/countup\.js
+jquery\.min\.js
 configure
 IAxisPointer$
 ICoordinateSystem$
diff --git a/build/addHeader.js b/build/addHeader.js
index 7a8f31e..7f74858 100644
--- a/build/addHeader.js
+++ b/build/addHeader.js
@@ -17,12 +17,18 @@
 * under the License.
 */
 
+/**
+ * Usage of `.rat-excludes`:
+ * For consistency, we use `.rat-excludes` for both Apache Rat and this tool.
+ * In the `.rat-excludes`, each line is a string of RegExp.
+ * Notice, the regular expression should match the entire path
+ * (a relative path based on `echarts` root).
+ */
+
 const fs = require('fs');
 const preamble = require('./preamble');
 const pathTool = require('path');
 const {color} = require('zrender/build/helper');
-// For consistency, we use `rat-excludes` for both Apache Rat and this tool.
-// Each item is a string of RegExp
 const excludesPath = pathTool.join(__dirname, '../.rat-excludes');
 const ecBasePath = pathTool.join(__dirname, '../');
 
@@ -60,7 +66,6 @@ function run() {
         const fileStr = fs.readFileSync(absolutePath, 'utf-8');
 
         const existLicense = preamble.extractLicense(fileStr, fileExt);
-        // !existLicense && console.log(absolutePath);
 
         if (existLicense) {
             passFiles.push(absolutePath);
@@ -73,7 +78,7 @@ function run() {
             return;
         }
 
-        fs.writeFileSync(absolutePath, preamble.addPreamble(fileStr, fileExt), 'utf-8');
+        // fs.writeFileSync(absolutePath, preamble.addPreamble(fileStr, fileExt), 'utf-8');
         updatedFiles.push(absolutePath);
     });
 
@@ -136,6 +141,12 @@ function eachFile(visit) {
         }
     }
 
+    // In Apache Rat, an item of the exclude file should be a regular expression
+    // that matches the entire relative path, like `pattern.matches(...)` of Java.
+    // See <https://github.com/sonatype/plexus-utils/blob/master/src/main/java/org/codehaus/plexus/util/AbstractScanner.java#L374>,
+    // That means that if a directory `some/dir` is in the exclude file,
+    // `some/dir/aa` will not be excluded, which is not expected conventionally,
+    // so we do not tread it like that.
     function prepareExcludePatterns() {
         const content = fs.readFileSync(excludesPath, {encoding: 'utf-8'});
         content.replace(/\r/g, '\n').split('\n').forEach(function (line) {
diff --git a/build/preamble.js b/build/preamble.js
index 3b0c5e8..dea0d63 100644
--- a/build/preamble.js
+++ b/build/preamble.js
@@ -156,7 +156,7 @@ function extractLicense(fileStr, fileExt) {
 }
 
 const cStyleCommentReg = /\/\*[\S\s]*?\*\//;
-const hashCommentReg = /^\s*#.*$/m;
+const hashCommentReg = /^\s*#.*$/gm;
 const mlCommentReg = /<\!\-\-[\S\s]*?\-\->/;
 const commentReg = {
     js: cStyleCommentReg,
@@ -167,11 +167,21 @@ const commentReg = {
 
 function extractComment(str, fileExt) {
     const reg = commentReg[fileExt];
+
     if (!fileExt || !reg || !str) {
         return;
     }
-    let result = cStyleCommentReg.exec(str);
-    return result && result[0];
+
+    reg.lastIndex = 0;
+
+    if (fileExt === 'sh') {
+        let result = str.match(reg);
+        return result && result.join('\n');
+    }
+    else {
+        let result = reg.exec(str);
+        return result && result[0];
+    }
 }
 
 module.exports = Object.assign({
diff --git a/build/rat.sh b/build/rat.sh
index 259c0d1..b7ce8b3 100644
--- a/build/rat.sh
+++ b/build/rat.sh
@@ -19,6 +19,6 @@
 basePath=$(cd `dirname $0`; pwd)
 ecPath=${basePath}/..
 
-java -jar "${basePath}/apache-rat-0.12.jar" --exclude-file "${ecPath}/.rat-excludes" --dir ${ecPath}
+java -jar "${basePath}/apache-rat-0.12.jar" --exclude-file "${ecPath}/.rat-excludes" --dir "${ecPath}"
 #  > "${basePath}/rat-result.txt"
 # java -jar "${basePath}/apache-rat/apache-rat-0.12.jar" -h
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
sushuang@apache.org.

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org