Skip to content

Commit

Permalink
JavaScript: Now 'make check-api/seguid-javascript' works [#12]
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikBengtsson committed Apr 30, 2024
1 parent 2e9971b commit 1e23691
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/check-javascript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,6 @@ jobs:
- name: Check CLI
if: runner.os != 'Windows'
run: make check-cli/seguid-javascript

- name: Check API
run: make check-api/seguid-python
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "tests/test_helper/bats-assert"]
path = tests-cli/test_helper/bats-assert
url = https://github.com/bats-core/bats-assert.git
[submodule "seguid-javascript"]
path = seguid-javascript
url = https://github.com/seguid/seguid-javascript
17 changes: 14 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ assert-bats:
@cd tests-cli && command -v "${BATS}" > /dev/null || { >&2 echo "ERROR: bats is not installed"; exit 1; }


# ------------------------------------------------------------
# Submodules
# ------------------------------------------------------------
add-submodules:
git submodule add https://github.com/seguid/seguid-javascript seguid-javascript

seguid-javascript:
git submodule init
git submodule update
cd "$@" && git pull origin main

# ------------------------------------------------------------
# Check CLI API
# ------------------------------------------------------------
Expand Down Expand Up @@ -44,8 +55,8 @@ check-api: assert-SCRIPT_CALL assert-bats
cd tests-api && $(BATS) *.bats

## FIXME: How do I use node/npm so it finds the 'seguid' module?
check-api/seguid-javascript:
$(MAKE) check-api SCRIPT_CALL="node" SCRIPT_PREAMBLE="const { seguid, lsseguid, ldseguid, csseguid, cdseguid } = require('seguid')" SCRIPT_PRINT_FMT="console.log(%s)" SCRIPT_ARGS_SEP=", "
check-api/seguid-javascript: seguid-javascript
$(MAKE) check-api NODE_PATH="$(shell pwd)/$<" SCRIPT_CALL="node" SCRIPT_PREAMBLE="const { seguid, lsseguid, ldseguid, csseguid, cdseguid } = require('seguid'); async function print(x) { try { const result = await x; console.log(result); } catch (error) { console.error(error); } }" SCRIPT_PRINT_FMT="print(%s)" SCRIPT_ARGS_SEP=", "

check-api/seguid-python:
$(MAKE) check-api SCRIPT_CALL="python" SCRIPT_PREAMBLE="from seguid import *" SCRIPT_PRINT_FMT="out=%s\nif isinstance(out, tuple):\n out=' '.join(out)\nprint(out)" SCRIPT_ARGS_SEP=", "
Expand All @@ -56,4 +67,4 @@ check-api/seguid-r:
check-api/seguid-tcl:
$(MAKE) check-api SCRIPT_CALL="tclsh" SCRIPT_PREAMBLE="source ../src/base64.tcl; source ../src/sha1.tcl; source ../src/seguid.tcl;" SCRIPT_PRINT_FMT="puts stdout [%s]" SCRIPT_ARGS_SEP=" " SCRIPT_CALL_FMT="%s %s"

check-api/ALL: check-api/seguid-python check-api/seguid-r
check-api/ALL: check-api/seguid-javascript check-api/seguid-python check-api/seguid-r
1 change: 1 addition & 0 deletions seguid-javascript
Submodule seguid-javascript added at b75f49

0 comments on commit 1e23691

Please sign in to comment.