-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ts
More file actions
40 lines (32 loc) · 1 KB
/
install.ts
File metadata and controls
40 lines (32 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import * as axios from 'axios'
import { createWriteStream } from 'fs'
import { join } from 'path'
import { cwd } from 'process'
import * as extract from 'extract-zip'
export namespace IntsallPackage {
export interface PackageData {
name :string
releaseName : string
releaseData : any;
}
export class Installer {
private readonly data:PackageData
constructor(data:PackageData) {
this.data = data
const file = this.getFile(this.data.releaseData)
}
private getFile = async (url:string) => {
const response = await axios.default({
method: 'GET',
url: url,
responseType: 'stream'
})
response.data.pipe(createWriteStream(join(
cwd(), "file.zip"
)))
await extract.default(join(cwd(), "file.zip"), {dir:this.data.name}, (error) =>{
console.log(error)
})
}
}
}