Skip to content

Commit

Permalink
chore: fix npm bin path
Browse files Browse the repository at this point in the history
  • Loading branch information
adikari committed Oct 4, 2022
1 parent d4607b7 commit df9fd4e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
28 changes: 16 additions & 12 deletions npm/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,32 @@ const PLATFORM_MAPPING = {

const name = 'safebox';
const version = packageJson.version;
const platform = process.platform;
const arch = process.arch;
const platform = PLATFORM_MAPPING[process.platform];
const arch = ARCH_MAPPING[process.arch];
const binaryName = platform === 'win32' ? `${name}.ext` : name;
const tarUrl = `https://github.com/adikari/safebox/releases/download/v${version}/safebox_${version}_${platform}_${arch}.tar.gz`;

const nodeBin = cp.execSync("npm bin").toString().replace(/\r?\n|\r/g, "");

const error = msg => {
console.error(msg);
process.exit(1);
};

if (!(arch in ARCH_MAPPING)) {
if (!arch) {
error(`${name} is not supported for this architecture: ${arch}`);
return;
}

if (!(platform in PLATFORM_MAPPING)) {
if (!platform) {
error(`${name} is not supported for this platform: ${platform}`);
return;
}

const nodeBin = path.join(__dirname, "../../.bin")

if (!fs.existsSync(nodeBin)){
fs.mkdirSync(nodeBin);
}

const error = msg => {
console.error(msg);
process.exit(1);
};

const install = () => {
const tmpdir = os.tmpdir();
const req = request({ uri: tarUrl });
Expand All @@ -58,7 +62,7 @@ const install = () => {

req.on('response', res => {
if (res.statusCode !== 200) {
return callback(`Error downloading safebox binary. HTTP Status Code: ${res.statusCode}`);
error(`Error downloading safebox binary from ${tarUrl}. HTTP Status Code: ${res.statusCode}`);
}

req.pipe(download);
Expand Down
4 changes: 2 additions & 2 deletions npm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adikari/safebox",
"version": "1.1.3",
"version": "1.1.4",
"description": "A Fast and Flexible secret manager built with love by adikari in Go",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit df9fd4e

Please sign in to comment.