I would like to unzip files using typescript. I have test.ts like below
var unzip = require('unzip-stream');
var fs = require('fs-extra');
class test {
unzipp() {
return fs.createReadStream('./e2e/chrome.zip').pipe(unzip.Extract({ path: './e2e' }));
}
}
But when I run
tsc test.ts
and then
node test.js
nothing happens.
Can anyone help with that please?
I would like to unzip files using typescript. I have test.ts like below
var unzip = require('unzip-stream');
var fs = require('fs-extra');
class test {
unzipp() {
return fs.createReadStream('./e2e/chrome.zip').pipe(unzip.Extract({ path: './e2e' }));
}
}
But when I run
tsc test.ts
and then
node test.js
nothing happens.
Can anyone help with that please?
Share Improve this question edited Jan 9, 2019 at 22:56 Daniel Beck 21.5k5 gold badges43 silver badges60 bronze badges asked Jan 9, 2019 at 22:50 EdXXEdXX 8902 gold badges15 silver badges35 bronze badges 1- 3 You have declared a class with a member method. Basically, you're telling node "I want to define this class that does something, then that's it. Don't do anything else. Just exit." – Patrick Roberts Commented Jan 9, 2019 at 22:56
2 Answers
Reset to default 3you have declared your class but you did not run it.
var myInstance = new test();
myInstance.unzipp();
As Patrick says in the ment, you're not actually running the code. You don't really need a class for this right now either. Try the following:
var unzip = require('unzip-stream');
var fs = require('fs-extra');
function unzip() {
return fs.createReadStream('./e2e/chrome.zip').pipe(unzip.Extract({ path: './e2e' }));
}
unzip();