Skip to content

Commit

Permalink
Make downloaded file executable
Browse files Browse the repository at this point in the history
  • Loading branch information
tscpp committed Mar 29, 2021
1 parent d5a25bf commit 6b19f52
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/bin/postinstall.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { https } from 'follow-redirects'
import { Extract } from 'unzipper'
import { resolve } from 'path'
import * as fs from 'fs'

const version = '3.11.4'
function platform() {
Expand All @@ -24,8 +25,12 @@ function arch() {
const url = `https://github.com/protocolbuffers/protobuf/releases/download/v${version}/protoc-${version}-${platform()}${arch()}.zip`
const destinationFolder = 'native'

const extension = process.platform == 'win32' ? '.exe' : ''
const protoc_path = resolve(__dirname, '../../native/bin/protoc' + extension)

console.log(url)
https.get(url, response => {
response.pipe(Extract({ path: destinationFolder }))
.on('close', () => fs.chmodSync(protoc_path, '0775'))
})

0 comments on commit 6b19f52

Please sign in to comment.