-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild-package.sh
executable file
·55 lines (47 loc) · 1.45 KB
/
build-package.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
set -e -u
cargo build --release --target wasm32-unknown-unknown
wasm-bindgen --target nodejs --out-dir target/nodejs ../../target/wasm32-unknown-unknown/release/advent_of_code_wasm.wasm
which wasm-opt
wasm-opt --version
wasm-opt --all-features --disable-gc -O3 -o target/nodejs/advent_of_code_wasm_bg.wasm-optimized target/nodejs/advent_of_code_wasm_bg.wasm
mv target/nodejs/advent_of_code_wasm_bg.wasm-optimized target/nodejs/advent_of_code_wasm_bg.wasm
cp README.md target/nodejs/
cp cli.js target/nodejs/
PACKAGE_VERSION=`cargo metadata --format-version 1 | jq -r '.packages[] | select(.name=="advent-of-code").version'`
cd target/nodejs
cat > package.json << EOF
{
"bin": {
"advent-of-code-wasm": "./cli.js"
},
"name": "advent-of-code-wasm",
"collaborators": [
"Fredrik Fornwall <[email protected]>"
],
"description": "Solutions to Advent of Code written in Rust",
"version": "$PACKAGE_VERSION",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/fornwall/advent-of-code"
},
"files": [
"advent_of_code_wasm_bg.wasm",
"advent_of_code_wasm.js",
"advent_of_code_wasm_bg.js",
"advent_of_code_wasm.d.ts",
"LICENSE.txt"
],
"main": "advent_of_code_wasm.js",
"types": "advent_of_code_wasm.d.ts"
}
EOF
cd ../../test-project
npm install
npm test
#OUTPUT=`echo 14 | npx advent-of-code-wasm 2019 1 1`
#if [ "$OUTPUT" != 3 ]; then
# echo "Invalid output: $OUTPUT"
# exit 1
#fi