浏览代码

feat: extract success remove zip

zhangyuhan 3 年之前
父节点
当前提交
b80de270b5
共有 3 个文件被更改,包括 13 次插入2 次删除
  1. 2 1
      package.json
  2. 4 1
      src/index.ts
  3. 7 0
      yarn.lock

+ 2 - 1
package.json

@@ -63,6 +63,7 @@
   "dependencies": {
   "dependencies": {
     "decompress": "^4.2.1",
     "decompress": "^4.2.1",
     "i18next": "^21.8.14",
     "i18next": "^21.8.14",
-    "node-downloader-helper": "^2.1.1"
+    "node-downloader-helper": "^2.1.1",
+    "rimraf": "^3.0.2"
   }
   }
 }
 }

+ 4 - 1
src/index.ts

@@ -4,6 +4,7 @@ const { DownloaderHelper } = require('node-downloader-helper')
 const decompress = require('decompress')
 const decompress = require('decompress')
 const path = require('path')
 const path = require('path')
 const fs = require('fs')
 const fs = require('fs')
+const rm = require('rimraf').sync
 
 
 export interface FormatParams {
 export interface FormatParams {
   type: string
   type: string
@@ -61,11 +62,13 @@ export default class DownloadRemoteProjectTemplate {
     }
     }
     return this.download(url, realDestinationFolder, this.hooks.getOptions()).then(async () => {
     return this.download(url, realDestinationFolder, this.hooks.getOptions()).then(async () => {
       if (extract) {
       if (extract) {
-        await decompress(path.resolve(realDestinationFolder, this.FileName), realDestinationFolder, {
+        const zipPath = path.resolve(realDestinationFolder, this.FileName)
+        await decompress(zipPath, realDestinationFolder, {
           filter: this.hooks.doFilterFiles,
           filter: this.hooks.doFilterFiles,
           strip: params.strip
           strip: params.strip
         }).then(() => {
         }).then(() => {
           console.log(i18next.t('success_extract'))
           console.log(i18next.t('success_extract'))
+          rm(zipPath)
         })
         })
       }
       }
     })
     })

+ 7 - 0
yarn.lock

@@ -5705,6 +5705,13 @@ rimraf@^3.0.0:
   dependencies:
   dependencies:
     glob "^7.1.3"
     glob "^7.1.3"
 
 
+rimraf@^3.0.2:
+  version "3.0.2"
+  resolved "http://192.168.3.207:4873/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
+  integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
+  dependencies:
+    glob "^7.1.3"
+
 rollup-plugin-sourcemaps@^0.6.2:
 rollup-plugin-sourcemaps@^0.6.2:
   version "0.6.3"
   version "0.6.3"
   resolved "https://registry.npmmirror.com/rollup-plugin-sourcemaps/-/rollup-plugin-sourcemaps-0.6.3.tgz#bf93913ffe056e414419607f1d02780d7ece84ed"
   resolved "https://registry.npmmirror.com/rollup-plugin-sourcemaps/-/rollup-plugin-sourcemaps-0.6.3.tgz#bf93913ffe056e414419607f1d02780d7ece84ed"