Skip to content

Commit

Permalink
feat: be nice to buggy npm
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed May 19, 2018
1 parent 89ee805 commit e90f20c
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
osx/7za filter=lfs diff=lfs merge=lfs -text
mac/7za filter=lfs diff=lfs merge=lfs -text
linux/ia32/7za filter=lfs diff=lfs merge=lfs -text
linux/x64/7za filter=lfs diff=lfs merge=lfs -text
*.dll filter=lfs diff=lfs merge=lfs -text
Expand Down
7 changes: 2 additions & 5 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
declare module "7zip-bin" {
export const path7za: string
export const path7x: string
export const pathCompressStdIn: string
}
export const path7za: string
export const path7x: string
27 changes: 16 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
"use strict"

const path = require("path")
function getPath() {
if (process.env.USE_SYSTEM_7ZA === "true") {
return "7za"
}

const nameMap = {
"darwin": "mac",
"win32": "win",
"linux": "linux",
const path = require("path")
if (process.platform === "darwin") {
return path.join(__dirname, "mac", "7za")
}
else if (process.platform === "win32") {
return path.join(__dirname, "win", process.arch, "7za.exe")
}
else {
return path.join(__dirname, "linux", process.arch, "7za")
}
}

const suffix = nameMap[process.platform]
if (suffix == null) {
throw new Error("Unsupported platform " + process.platform)
}
exports.path7za = process.env.USE_SYSTEM_7ZA === "true" ? "7za" : require(`./${suffix}`).path7za
exports.path7x = path.join(__dirname, "7x.sh")
exports.path7za = getPath()
exports.path7x = path.join(__dirname, "7x.sh")
3 changes: 0 additions & 3 deletions linux/index.js

This file was deleted.

3 changes: 0 additions & 3 deletions mac/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "7zip-bin",
"description": "7-Zip precompiled binaries",
"version": "3.1.0",
"version": "4.0.1",
"files": [
"*.js",
"7x.sh",
Expand Down
3 changes: 0 additions & 3 deletions win/index.js

This file was deleted.

0 comments on commit e90f20c

Please sign in to comment.