adhere better to GNU guidlines
This commit is contained in:
parent
54fec75279
commit
10df69131f
2
.gitignore
vendored
2
.gitignore
vendored
@ -11,3 +11,5 @@ node_modules
|
||||
yarn-error.log
|
||||
|
||||
npm-packages-offline-cache/
|
||||
|
||||
config.mk
|
||||
|
16
Makefile
16
Makefile
@ -9,6 +9,7 @@ ava = node_modules/ava/cli.js
|
||||
nyc = node_modules/nyc/bin/nyc.js
|
||||
tslint = node_modules/tslint/bin/tslint
|
||||
|
||||
-include config.mk
|
||||
|
||||
.PHONY: package-stable
|
||||
package-stable: i18n
|
||||
@ -40,7 +41,6 @@ typedoc:
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf build/
|
||||
rm -rf dist/
|
||||
|
||||
.PHONY: check
|
||||
@ -70,3 +70,17 @@ i18n: yarn-install
|
||||
done;
|
||||
# generate .ts file containing all translations
|
||||
$(gulp) po2js
|
||||
|
||||
|
||||
ifndef prefix
|
||||
.PHONY: install
|
||||
install:
|
||||
@echo "no prefix configured, did you run ./configure?"
|
||||
else
|
||||
.PHONY: install
|
||||
install:
|
||||
@echo "installing to" $(prefix)
|
||||
npm install -g --prefix $(prefix) .
|
||||
endif
|
||||
|
||||
|
||||
|
57
configure
vendored
57
configure
vendored
@ -2,6 +2,63 @@
|
||||
|
||||
set -eu
|
||||
|
||||
prefix=/usr/local
|
||||
|
||||
usage() {
|
||||
echo "Usage: ./configure [OPTION]"
|
||||
echo
|
||||
echo "Configuration:"
|
||||
echo " -h, --help display this help and exit"
|
||||
echo
|
||||
echo "Installation directories:"
|
||||
echo " --prefix=PREFIX install architecture-independent files in PREFIX [$prefix]"
|
||||
}
|
||||
|
||||
|
||||
# -allow a command to fail with !’s side effect on errexit
|
||||
# -use return value from ${PIPESTATUS[0]}, because ! hosed $?
|
||||
! getopt --test > /dev/null
|
||||
if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
|
||||
echo 'getopt not available'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LONGOPTS=prefix:,help
|
||||
OPTIONS=h
|
||||
|
||||
! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@")
|
||||
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
|
||||
# e.g. return value is 1
|
||||
# then getopt has complained about wrong arguments to stdout
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# read getopt’s output this way to handle the quoting right:
|
||||
eval set -- "$PARSED"
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
--prefix)
|
||||
prefix="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "Programming error"
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "prefix=$prefix" >config.mk
|
||||
|
||||
node_version=$(node --version)
|
||||
if [ ! "$?" -eq 0 ]; then
|
||||
echo 'Error: node executable not found.'
|
||||
|
@ -20,14 +20,12 @@
|
||||
import { Wallet } from "../wallet";
|
||||
import { getDefaultNodeWallet } from "../headless/helpers";
|
||||
|
||||
|
||||
class AndroidWalletHelper {
|
||||
wallet: Wallet | undefined;
|
||||
constructor (private sendMessage: (m: any) => void) {
|
||||
}
|
||||
walletPromise: Promise<Wallet> | undefined;
|
||||
constructor() {}
|
||||
|
||||
async init() {
|
||||
this.wallet = await getDefaultNodeWallet();
|
||||
this.walletPromise = getDefaultNodeWallet();
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,19 +33,25 @@ export function installAndroidWalletListener() {
|
||||
// @ts-ignore
|
||||
const sendMessage: (m: any) => void = global.__akono_sendMessage;
|
||||
if (typeof sendMessage !== "function") {
|
||||
const errMsg = "FATAL: cannot install android wallet listener: akono functions missing";
|
||||
const errMsg =
|
||||
"FATAL: cannot install android wallet listener: akono functions missing";
|
||||
console.error(errMsg);
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
const walletHelper = new AndroidWalletHelper(sendMessage);
|
||||
const walletHelper = new AndroidWalletHelper();
|
||||
const onMessage = (msg: any) => {
|
||||
const operation = msg.operation;
|
||||
if (typeof operation !== "string") {
|
||||
console.error("message to android wallet helper must contain operation of type string");
|
||||
console.error(
|
||||
"message to android wallet helper must contain operation of type string",
|
||||
);
|
||||
return;
|
||||
}
|
||||
const id = msg.id;
|
||||
let result;
|
||||
switch (operation) {
|
||||
case "init":
|
||||
result = walletHelper.init();
|
||||
break;
|
||||
case "getBalances":
|
||||
break;
|
||||
@ -57,7 +61,11 @@ export function installAndroidWalletListener() {
|
||||
console.error(`operation "${operation}" not understood`);
|
||||
return;
|
||||
}
|
||||
|
||||
const respMsg = { result, id };
|
||||
console.log("sending message back", respMsg);
|
||||
sendMessage(respMsg);
|
||||
};
|
||||
// @ts-ignore
|
||||
globalThis.__akono_onMessage = onMessage;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user