diff --git a/package-lock.json b/package-lock.json index 4cff669..1f8ad5f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,11 @@ "integrity": "sha512-UWkRY9X7RQHp5OhhRIIka58/gVVycL1zHZu0OTsT5LI86ABaMOSbUjAl+b0FeDhQcxclrkyft3kW5QWdMRs8wQ==", "dev": true }, + "adm-zip": { + "version": "0.4.7", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.7.tgz", + "integrity": "sha1-hgbCy/HEJs6MjsABdER/1Jtur8E=" + }, "ajv": { "version": "5.5.2", "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", @@ -186,15 +191,6 @@ "integrity": "sha1-5tXqjF2tABMEpwsiY4RH9pyy+Ak=", "dev": true }, - "binary": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz", - "integrity": "sha1-n2BVO8XOjDOG87VTz/R0Yq3sqnk=", - "requires": { - "buffers": "0.1.1", - "chainsaw": "0.1.0" - } - }, "block-stream": { "version": "0.0.9", "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", @@ -244,24 +240,11 @@ "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", "dev": true }, - "buffers": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz", - "integrity": "sha1-skV5w77U1tOWru5tmorn9Ugqt7s=" - }, "caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" }, - "chainsaw": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/chainsaw/-/chainsaw-0.1.0.tgz", - "integrity": "sha1-XqtQsor+WAdNDVgpE4iCi15fvJg=", - "requires": { - "traverse": "0.3.9" - } - }, "chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", @@ -708,17 +691,6 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, - "fstream": { - "version": "0.1.31", - "resolved": "https://registry.npmjs.org/fstream/-/fstream-0.1.31.tgz", - "integrity": "sha1-czfwWPu7vvqMn1YaKMqwhJICyYg=", - "requires": { - "graceful-fs": "3.0.11", - "inherits": "2.0.3", - "mkdirp": "0.5.1", - "rimraf": "2.6.1" - } - }, "generate-function": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", @@ -851,14 +823,6 @@ "sparkles": "1.0.0" } }, - "graceful-fs": { - "version": "3.0.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.11.tgz", - "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=", - "requires": { - "natives": "1.1.0" - } - }, "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", @@ -1521,7 +1485,8 @@ "isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true }, "isobject": { "version": "2.1.0", @@ -1791,15 +1756,6 @@ "integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=", "dev": true }, - "match-stream": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/match-stream/-/match-stream-0.0.2.tgz", - "integrity": "sha1-mesFAJOzTf+t5CG5rAtBCpz6F88=", - "requires": { - "buffers": "0.1.1", - "readable-stream": "1.0.34" - } - }, "merge-stream": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-1.0.1.tgz", @@ -1976,11 +1932,6 @@ "duplexer2": "0.0.2" } }, - "natives": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.0.tgz", - "integrity": "sha1-6f+EFBimsux6SV6TmYT3jxY+bjE=" - }, "ncp": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz", @@ -2096,11 +2047,6 @@ } } }, - "over": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/over/-/over-0.0.5.tgz", - "integrity": "sha1-8phS5w/X4l82DgE6jsRMgq7bVwg=" - }, "parse-glob": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", @@ -2201,17 +2147,6 @@ "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, - "pullstream": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/pullstream/-/pullstream-0.4.1.tgz", - "integrity": "sha1-1vs79a7Wl+gxFQ6xACwlo/iuExQ=", - "requires": { - "over": "0.0.5", - "readable-stream": "1.0.34", - "setimmediate": "1.0.5", - "slice-stream": "1.0.0" - } - }, "punycode": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", @@ -2282,6 +2217,7 @@ "version": "1.0.34", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true, "requires": { "core-util-is": "1.0.2", "inherits": "2.0.3", @@ -2366,9 +2302,9 @@ "dev": true }, "rimraf": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.1.tgz", - "integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=", + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "requires": { "glob": "7.1.2" } @@ -2392,19 +2328,6 @@ "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, - "setimmediate": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", - "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=" - }, - "slice-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/slice-stream/-/slice-stream-1.0.0.tgz", - "integrity": "sha1-WzO9ZvATsaf4ZGCwPUY97DmtPqA=", - "requires": { - "readable-stream": "1.0.34" - } - }, "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", @@ -2529,7 +2452,8 @@ "string_decoder": { "version": "0.10.31", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true }, "stringstream": { "version": "0.0.5", @@ -2593,7 +2517,7 @@ "graceful-fs": "4.1.11", "inherits": "2.0.3", "mkdirp": "0.5.1", - "rimraf": "2.6.1" + "rimraf": "2.6.2" } }, "graceful-fs": { @@ -2701,11 +2625,6 @@ "punycode": "1.4.1" } }, - "traverse": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz", - "integrity": "sha1-cXuPIgzAu3tE5AUUwisui7xw2Lk=" - }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -2736,19 +2655,6 @@ "through2-filter": "2.0.0" } }, - "unzip": { - "version": "0.1.11", - "resolved": "https://registry.npmjs.org/unzip/-/unzip-0.1.11.tgz", - "integrity": "sha1-iXScY7BY19kNYZ+GuYqhU107l/A=", - "requires": { - "binary": "0.3.0", - "fstream": "0.1.31", - "match-stream": "0.0.2", - "pullstream": "0.4.1", - "readable-stream": "1.0.34", - "setimmediate": "1.0.5" - } - }, "url-parse": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.2.0.tgz", diff --git a/package.json b/package.json index 991c3ed..0e12477 100644 --- a/package.json +++ b/package.json @@ -589,14 +589,15 @@ "request": "^2.85.0", "request-progress": "^3.0.0", "jsonc-parser": "^1.0.3", - "unzip": "^0.1.11", + "adm-zip": "^0.4.7", "async": "^2.6.0", "ncp": "^2.0.0", "rmdir": "^1.2.0", "line-by-line": "^0.1.6", "vscode-languageclient": "^4.1.3", "mkdirp": "^0.5.1", - "opn": "^5.3.0" + "opn": "^5.3.0", + "rimraf": "^2.6.2" }, "devDependencies": { "typescript": "^2.8.1", diff --git a/src/installer.ts b/src/installer.ts index 3261e7c..a8534b2 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -5,7 +5,8 @@ import * as fs from "fs" import { req } from "./util" import { config } from "./extension" import { platform } from "os"; -var unzip = require("unzip"); +var rimraf = require("rimraf"); +var AdmZip = require("adm-zip"); var progress = require("request-progress"); var async = require("async"); var rmdir = require("rmdir"); @@ -95,15 +96,14 @@ export function downloadDub(env: any, done: Function) { }).pipe(fs.createWriteStream(outputPath)).on("finish", () => { installationLog.appendLine("Extracting dub"); if (ext == ".zip") { - fs.createReadStream(outputPath).pipe(unzip.Extract({ path: outputFolder })).on("finish", () => { - config().update("dubPath", finalDestination, true); - installationLog.appendLine("Deleting " + outputPath); - fs.unlink(outputPath, (err) => { - if (err) - installationLog.appendLine("Failed to delete " + outputPath); - }); - done(true); + new AdmZip(outputPath).extractAllTo(outputFolder); + config().update("dubPath", finalDestination, true); + installationLog.appendLine("Deleting " + outputPath); + fs.unlink(outputPath, (err) => { + if (err) + installationLog.appendLine("Failed to delete " + outputPath); }); + done(true); } else if (ext == ".tar.gz") { installationLog.appendLine("> tar -zxvf dub" + ext); @@ -157,7 +157,7 @@ export function installServeD(env: any, done: Function) { if (!exists) fs.mkdirSync(outputFolder); if (fs.existsSync(finalDestination)) - fs.unlinkSync(finalDestination); + rimraf.sync(finalDestination); async.each(urls, function (url: string, cb: Function) { output.appendLine("Downloading from " + url + " into " + outputFolder); var fileName = path.basename(url, ext); @@ -168,19 +168,18 @@ export function installServeD(env: any, done: Function) { output.appendLine("Extracting " + fileName); if (ext == ".zip") { try { - fs.createReadStream(outputPath).pipe(unzip.Extract({ path: outputFolder })).on("finish", () => { - try { - output.appendLine("Deleting " + outputPath); - fs.unlink(outputPath, (err) => { - if (err) - output.appendLine("Failed to delete " + outputPath); - }); - } - catch (e) { - vscode.window.showErrorMessage("Failed to delete temporary file: " + outputPath); - } - cb(); - }); + new AdmZip(outputPath).extractAllTo(outputFolder); + try { + output.appendLine("Deleting " + outputPath); + fs.unlink(outputPath, (err) => { + if (err) + output.appendLine("Failed to delete " + outputPath); + }); + } + catch (e) { + vscode.window.showErrorMessage("Failed to delete temporary file: " + outputPath); + } + cb(); } catch (e) { return cb(e);