Skip to content

Commit

Permalink
bundler add --test option
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeTWC1984 committed Feb 14, 2024
1 parent 96f8b5f commit ba4b34f
Show file tree
Hide file tree
Showing 3 changed files with 412 additions and 15 deletions.
19 changes: 18 additions & 1 deletion bundle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ writehead() {
printf "\n ---- $1 [$(date +"%T")]\n"
}


# check for custom nodejs binary
if [ -f $PWD/nodejs/bin/node ]; then
export PATH="$PWD/nodejs/bin:$PATH"
echo "using custom node version: $(node -v)"
fi

# -------------------- ARG CHECK
x=0
dist="dist" # default
Expand All @@ -24,6 +31,7 @@ while (( "$#" )); do
--sql ) sql=1 ;;
--oracle ) oracle=1 ;;
--mssql ) mssql=1 ;;
--test ) test=1 ;; # run unit test at the end
--dev | -d ) dev=1 ;; # avoid minification, add verbosity
--verbose | -v ) verbose=1 ;;
--force | -f ) force=1 ;; # reinstall npm packages
Expand Down Expand Up @@ -315,7 +323,6 @@ if [ "$redis" = 1 ]; then
esbuild --bundle --log-level=$ESBuildLogLevel $minify --platform=node --outdir=$dist/bin/engines engines/Redis.js
fi


# --- CRONICLE.JS
writehead "Bundling cronicle.js"
esbuild --bundle --log-level=$ESBuildLogLevel $minify --keep-names --platform=node --outfile=$dist/bin/cronicle.js lib/main.js
Expand Down Expand Up @@ -419,3 +426,13 @@ To remove service:
---------------------------------------------------------------------------------------------------------------------------------------
EOF

# OPTIONAL UNIT TEST
if [ "$test" = 1 ]; then
writehead " Bundling unit test files"
esbuild --bundle --log-level=info --minify=false --platform=node --outdir=$dist/bin lib/test.js
writehead " Running tests"
node node_modules/pixl-unit/unit.js $dist/bin/test.js
# remove test files
rm $dist/bin/test.js
fi
5 changes: 1 addition & 4 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,10 @@ module.exports = {
function testAPIConfig(test) {
// test app/config api
var params = {};
request.json( api_url + '/app/config', params, function(err, resp, data) {
request.get( api_url + '/app/config', params, function(err, resp, data) {

test.ok( !err, "No error requesting API" );
test.ok( resp.statusCode == 200, "HTTP 200 from API" );
test.ok( "code" in data, "Found code prop in JSON response" );
test.ok( data.code == 0, "Code is zero (no error)" );
test.ok( !!data.config, "Found config in response data" );

test.done();
} );
Expand Down
Loading

0 comments on commit ba4b34f

Please sign in to comment.