Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 'unzipper' node module instead of system 'unzip' #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const fs = require('fs');
const path = require('path');
const fsp = require('fs-promise');
const exec = require('child_process').exec;
const unzipper = require('unzipper');
const { Storage } = require('@google-cloud/storage');

function AppNotFoundError(message) {
let error = new Error(message);
Expand All @@ -12,9 +14,7 @@ function AppNotFoundError(message) {
return error;
}

let gcloud = require('gcloud');

let storage = gcloud.storage();
let storage = new Storage();

/*
* Downloader class that downloads the latest version of the deployed
Expand Down Expand Up @@ -102,10 +102,14 @@ class GCloudStorageDownloader {
unzipApp() {
let zipPath = this.zipPath;

return this.exec('unzip ' + zipPath)
.then(() => {
this.ui.writeLine("unzipped " + zipPath);
});
return new Promise((resolve, reject) => {
const stream = fs.createReadStream(zipPath);
stream.pipe(unzipper.Extract({ path: process.cwd() }));
stream.on("end", resolve);
stream.on("error", reject);
}).then(() => {
this.ui.writeLine("unzipped " + zipPath);
});
}

installNPMDependencies() {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
},
"homepage": "https://github.com/EmberSherpa/fastboot-gcloud-storage-downloader#readme",
"dependencies": {
"fs-promise": "0.5.0",
"gcloud": "0.32.0"
"@google-cloud/storage": "^4.1.0",
"fs-promise": "2.0.3",
"unzipper": "^0.10.5"
}
}
Loading