diff --git a/package.json b/package.json index 4f01d2ce..bd256cb2 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "build": "cross-env NODE_ENV=production webpack && tsc -b -v && cross-env BABEL_ENV=production babel target/renderer/bundle.js --out-file target/renderer/bundle.js --no-comments --minified", "lint": "eslint . --fix --ext .js,.jsx,.ts,.tsx,.json", "test": "yarn run lint && yarn run test:unit", - "test:unit": "tsc -b app/tsconfig.json && node --eval \"const{cpSync,mkdirSync}=require('fs');const{basename}=require('path');mkdirSync('dist/tmp/root/app',{recursive:true});cpSync('target','dist/tmp/root/app',{recursive:true,filter:function(s){const b=basename(s);if(b==='node_modules'||b==='renderer')return false;return true;}})\" && cross-env DEBUG=ava:watcher AVA_IMPORT_FROM_PROJECT_NO_STUB=1 ava --no-cache", + "test:unit": "zx test-unit.mjs", "test:unit:watch": "yarn run test:unit -- --watch", "test:e2e": "cross-env DEBUG=ava:watcher AVA_IMPORT_FROM_PROJECT_NO_STUB=1 ava --no-cache --config ava-e2e.config.js", "postinstall": "yarn run v8-snapshot && webpack --config-name hyper-app && yarn run install-app-deps-with-retry && yarn run rebuild-node-pty && cpy --cwd=target node_modules \"../../app/\" && husky && yarn run generate-schema", @@ -146,7 +146,8 @@ "ts-node": "10.9.2", "typescript": "5.7.2", "uuaw": "^1.2.2", - "webpack": "5.96.1" + "webpack": "5.96.1", + "zx": "^8.8.5" }, "electronmon": { "patterns": [ diff --git a/test-unit.mjs b/test-unit.mjs new file mode 100755 index 00000000..44e1d410 --- /dev/null +++ b/test-unit.mjs @@ -0,0 +1,27 @@ +#!/usr/bin/env zx + +import { cpSync, mkdirSync } from 'fs'; +import { basename } from 'path'; + +$.prefix = 'set -e;'; + +await $`tsc -b app/tsconfig.json`.pipe(process.stdout); + +await mkdirSync('dist/tmp/root/app', { recursive: true }); + +await cpSync( + 'target', + 'dist/tmp/root/app', + { + recursive: true, + filter: function (s) { + const b = basename(s); + if (b === 'node_modules' || b === 'renderer') { + return false; + } + return true; + } + } +) + +await $`cross-env DEBUG=ava:watcher AVA_IMPORT_FROM_PROJECT_NO_STUB=1 ava --no-cache`.pipe(process.stdout); \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index b3210627..32e76610 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7830,3 +7830,8 @@ yoctocolors@^2.1.1: version "2.1.2" resolved "https://registry.npmjs.org/yoctocolors/-/yoctocolors-2.1.2.tgz#d795f54d173494e7d8db93150cec0ed7f678c83a" integrity sha512-CzhO+pFNo8ajLM2d2IW/R93ipy99LWjtwblvC1RsoSUMZgyLbYFr221TnSNT7GjGdYui6P459mw9JH/g/zW2ug== + +zx@^8.8.5: + version "8.8.5" + resolved "https://registry.npmjs.org/zx/-/zx-8.8.5.tgz#d092d8c0017aa7c5a276fda88ff19e4b1d91cc64" + integrity sha512-SNgDF5L0gfN7FwVOdEFguY3orU5AkfFZm9B5YSHog/UDHv+lvmd82ZAsOenOkQixigwH2+yyH198AwNdKhj+RA==