From e89fd549968105770f08823ff993c69c3b833a1e Mon Sep 17 00:00:00 2001
From: "xiaofeng.mxf" <xiaofeng.mxf@taobao.com>
Date: Mon, 20 Jan 2020 20:41:03 +0800
Subject: [PATCH] add before_script for CI

---
 .travis.yml     | 4 +++-
 bin/anyproxy-ca | 8 +++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 6248f8a..b0fd0da 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,4 +2,6 @@ language: node_js
 node_js:
   - 8
   - 10
-  - 12
\ No newline at end of file
+  - 12
+before_script:
+  - node ./bin/anyproxy-ca -g
\ No newline at end of file
diff --git a/bin/anyproxy-ca b/bin/anyproxy-ca
index f03a60f..85a71f7 100755
--- a/bin/anyproxy-ca
+++ b/bin/anyproxy-ca
@@ -20,10 +20,10 @@ program
   .parse(process.argv);
 
 function openFolderOfFile(filePath) {
-  const isWin = /^win/.test(process.platform);
-  if (isWin) {
+  const platform = process.platform;
+  if (/^win/.test(platform)) {
     exec('start .', { cwd: path.dirname(filePath) });
-  } else {
+  } else if (/darwin/.test(platform)) {
     exec(`open -R ${filePath}`);
   }
 }
@@ -33,7 +33,6 @@ function guideToGenrateCA() {
     if (!error) {
       const certDir = path.dirname(keyPath);
       console.log(`The cert is generated at ${certDir}. Please trust the ${color.bold('rootCA.crt')}.`);
-      // TODO: console.log('guide to install');
       openFolderOfFile(crtPath);
     } else {
       console.error('failed to generate rootCA', error);
@@ -44,7 +43,6 @@ function guideToGenrateCA() {
 function guideToTrustCA() {
   const certPath = AnyProxy.utils.certMgr.getRootCAFilePath();
   if (certPath) {
-    // TODO: console.log('guide to install');
     openFolderOfFile(certPath);
   } else {
     console.error('failed to get cert path');