diff --git a/package.json b/package.json index 3c6c3e1535d340db6cfc069e96af21dca687662c..96e6202a5269625f33a282f60b4e5a295c2256a7 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "ts-node": "ts-node", "test": "npm run clean && npm run lint && npm run test:unit:retry && npm run test:shell && npm run sloc", "test:linux": "npm run pretest && parallel ts-node -- ./src/**/*.spec.ts ./tests/**/*.spec.ts && npm run posttest", - "test:pack": "npm run dist && export TMPDIR=/tmp/wechaty.$$ && npm pack && mkdir $TMPDIR && mv wechaty-*.*.*.tgz $TMPDIR && cp tests/fixtures/smoke-testing.js $TMPDIR && cd $TMPDIR && npm init -y && npm i wechaty-*.*.*.tgz && (for i in {1..3}; do node smoke-testing.js && break || sleep 1; done)", + "test:pack": "bash -x scripts/npm-pack-testing.sh", "test:shell": "shellcheck bin/*.sh", "test:unit": "blue-tape -r ts-node/register \"src/**/*.spec.ts\" \"src/*.spec.ts\" \"tests/*.spec.ts\" \"tests/**/*.spec.ts\"", "test:unit:retry": "ts-node scripts/retry-unit-tests", diff --git a/scripts/npm-pack-testing.sh b/scripts/npm-pack-testing.sh new file mode 100755 index 0000000000000000000000000000000000000000..f247be4c9858453d5c2636b60dfb5f3303e25058 --- /dev/null +++ b/scripts/npm-pack-testing.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -e + +npm run dist +npm pack + +TMPDIR="/tmp/npm-pack-testing.$$" +mkdir "$TMPDIR" +mv *-*.*.*.tgz "$TMPDIR" +cp tests/fixtures/smoke-testing.ts "$TMPDIR" + +cd $TMPDIR +npm init -y +npm install *-*.*.*.tgz \ + rxjs \ + brolog \ + typescript@latest + +./node_modules/.bin/tsc \ + --lib esnext,dom \ + --noEmitOnError \ + --noImplicitAny \ + --skipLibCheck \ + smoke-testing.ts + +node smoke-testing.js +# (for i in {1..3}; do node smoke-testing.js && break || sleep 1; done) diff --git a/tests/fixtures/smoke-testing.js b/tests/fixtures/smoke-testing.ts similarity index 90% rename from tests/fixtures/smoke-testing.js rename to tests/fixtures/smoke-testing.ts index 3f42aca091b220fa8fa52cab0c5aecb4a5758272..5ad9880b2d3f3d83230f255b052ef503227bc0f7 100644 --- a/tests/fixtures/smoke-testing.js +++ b/tests/fixtures/smoke-testing.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node -const { Wechaty } = require('wechaty') +import { Wechaty } from 'wechaty' async function main() { const bot = Wechaty.instance()