From 38f961138ea04f3325c2c6c4b836455a372e75fd Mon Sep 17 00:00:00 2001 From: codearoni Date: Wed, 25 Mar 2020 20:59:51 -0500 Subject: [PATCH] Updated postInstall script and readme. --- README.md | 21 +++++++++++---------- postInstall.js | 35 +++++++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 7cb965d..e514865 100644 --- a/README.md +++ b/README.md @@ -16,26 +16,27 @@ npm install zxp-provider # Usage -zxp-provider has a simple interface for calling ZXPSignCmd. Most users will want to use the 'bin' property, which will provide the zxp binary appropriate to your OS. +zxp-provider has a simple interface for calling ZXPSignCmd. Most users will want to call zxp-provider with no arguments. This will return the latest version of ZXPSignCmd, for your current running operating system. ```javascript -var zxp = require('zxp-provider').bin; +const zxpProvider = require('zxp-provider'); +const zxp = zxpProvider(); // returns the lastest version for the current operation system ``` -If you would like to manually choose the executable, zxp-provider provides an interface for that as well. +If you would like to manually choose the version of ZXPSignCmd, an interface is provided for that. Please see CEP-Resources if you're unsure what versions are available. If you would like, zxp-provider also contains an Array of supported versions. ```javascript -var zxpWin32 = require('zxp-provider').win32; +const chosenVersion = zxpProvider.supportedVersions[0]; // select the oldest version of ZXPSignCmd +const zxp = zxpProvider({ version: chosenVersion }); +``` -var zxpWin64 = require('zxp-provider').win64; +If you would like to manually select the os, you can do that as well. zxp-provider exposes an object containing all of the supported versions. -var zxpOsx = require('zxp-provider').osx; +```javascript +const win64 = zxpProvider.supportedPlatforms.win64; // manually select windows 64 bit +const zxp = zxpProvider({ os: win64 }) ``` # Notes -zxp-provider v1.0.x - ZxpSignCmd v3.0.30 - -zxp-provider v1.1.x - ZxpSignCmd v4.0.7 - [CEP-Resources](https://github.com/Adobe-CEP/CEP-Resources) diff --git a/postInstall.js b/postInstall.js index 4bead21..0ccef97 100644 --- a/postInstall.js +++ b/postInstall.js @@ -1,16 +1,31 @@ 'use strict'; +const util = require('util'); const fs = require('fs'); const path = require('path'); const os = require('os'); +const readdir = util.promisify(fs.readdir); +const chmod = util.promisify(fs.chmod); -if (os.type() === 'Darwin') { - console.log('Updating permissions for /bin/osx...'); - fs.chmod(path.resolve('./bin/osx/ZXPSignCmd'), '755', function (err) { - if (err) { - throw err; - } else { - console.log('Permissions for /bin/osx set to 755.'); - } - }); -} +const ZXP_SIGN_CMD = 'ZXPSignCmd'; +const BIN_DIR = path.resolve('./bin'); +const PERM_CODE = '755'; + +const chmodBinary = async (version) => { + const zxpPath = path.join(BIN_DIR, version, 'osx', ZXP_SIGN_CMD); + await chmod(zxpPath, PERM_CODE); + console.log(ZXP_SIGN_CMD + ' perms set to ' + PERM_CODE + ' at: ' + zxpPath); +}; + +(async () => { + if (os.type() === 'Darwin') { + console.log('Updating permissions for osx binaries.'); + const versionDirectories = await readdir(BIN_DIR); + const chmodSet = []; + versionDirectories.forEach((version) => { + chmodSet.push(chmodBinary(version)); + }); + + await Promise.all(chmodSet); + } +})();