Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@evilmartians/lefthook-installer

Package Overview
Dependencies
Maintainers
6
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@evilmartians/lefthook-installer - npm Package Compare versions

Comparing version 1.6.21 to 1.6.22

62

install.js

@@ -1,2 +0,5 @@

const { spawnSync } = require("child_process")
const http = require('https')
const fs = require('fs')
const path = require("path")
const chp = require("child_process")

@@ -9,11 +12,15 @@ const iswin = ["win32", "cygwin"].includes(process.platform)

}
const exePath = await downloadBinary()
const downloadURL = getDownloadURL()
const extension = iswin ? ".exe" : ""
const fileName = `lefthook${extension}`
const exePath = path.join(__dirname, "bin", fileName)
await downloadBinary(downloadURL, exePath)
console.log('downloaded to', exePath)
if (!iswin) {
const { chmodSync } = require("fs")
chmodSync(exePath, "755")
fs.chmodSync(exePath, "755")
}
// run install
spawnSync(exePath, ["install", "-f"], {
chp.spawnSync(exePath, ['install', '-f'], {
cwd: process.env.INIT_CWD || process.cwd(),
stdio: "inherit",
stdio: 'inherit',
})

@@ -50,24 +57,27 @@ }

const { DownloaderHelper } = require("node-downloader-helper")
const path = require("path")
async function downloadBinary(url, dest) {
console.log('downloading', url)
const file = fs.createWriteStream(dest)
return new Promise((resolve, reject) => {
http.get(url, function(response) {
if (response.statusCode === 302 && response.headers.location) {
// If the response is a 302 redirect, follow the new location
downloadBinary(response.headers.location, dest)
.then(resolve)
.catch(reject)
} else {
response.pipe(file)
async function downloadBinary() {
// TODO zip the binaries to reduce the download size
const downloadURL = getDownloadURL()
const extension = iswin ? ".exe" : ""
const fileName = `lefthook${extension}`
const binDir = path.join(__dirname, "bin")
const dl = new DownloaderHelper(downloadURL, binDir, {
fileName,
retry: { maxRetries: 5, delay: 50 },
file.on('finish', function() {
file.close(() => {
resolve(dest)
})
})
}
}).on('error', function(err) {
fs.unlink(file, () => {
reject(err)
})
})
})
dl.on("end", () => console.log("lefthook binary was downloaded"))
try {
await dl.start()
} catch(e) {
const message = `Failed to download ${fileName}: ${e.message} while fetching ${downloadURL}`
console.error(message)
throw new Error(message)
}
return path.join(binDir, fileName)
}

@@ -74,0 +84,0 @@

{
"name": "@evilmartians/lefthook-installer",
"version": "1.6.21",
"version": "1.6.22",
"description": "Simple git hooks manager",

@@ -32,8 +32,4 @@ "main": "bin/index.js",

"scripts": {
"version": "cp -f ../../README.md ./",
"install": "node install.js"
},
"dependencies": {
"node-downloader-helper": "^1.0.18"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc