Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

Commit

Permalink
adds scripts to publish and fix node import
Browse files Browse the repository at this point in the history
  • Loading branch information
kianenigma committed Feb 14, 2019
1 parent b473fbb commit 05c1c99
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pack-node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env node

const fs = require('fs');
const buffer = fs.readFileSync('./pkg/schnorrkel_js_bg.wasm');

fs.writeFileSync('./pkg/schnorrkel_js_bg.js', `
const imports = {};
imports['./schnorrkel_js'] = require('./schnorrkel_js');
const bytes = Buffer.from('${buffer.toString('base64')}', 'base64');
const wasmModule = new WebAssembly.Module(bytes);
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
module.exports = wasmInstance.exports;
`);
13 changes: 13 additions & 0 deletions pre-publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

# Compile the latest version; update ./pkg and readme files in it.
wasm-pack build --target browser

# Fix the name
sed -i -e 's/schnorrkel-js/@parity\/schnorrkel-js/g' pkg/package.json

# Run the script to fix node/browser import support
./pack-node.sh

# publish
# wasm-pack publish

0 comments on commit 05c1c99

Please sign in to comment.