最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - unzip files using typescript - Stack Overflow

programmeradmin1浏览0评论

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
Add a ment  | 

2 Answers 2

Reset to default 3

you 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();
发布评论

评论列表(0)

  1. 暂无评论