Skip to content
This repository was archived by the owner on Jun 19, 2021. It is now read-only.

Commit db87796

Browse files
committed
fix(shim): fix uncaught error on asking devicename
1 parent 6160746 commit db87796

File tree

5 files changed

+7
-17
lines changed

5 files changed

+7
-17
lines changed

package-lock.json

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
"rollup-plugin-node-resolve": "^4.0.0",
4848
"rollup-plugin-prettier": "^0.5.0",
4949
"rollup-plugin-run": "git+https://github.com/DrSensor/rollup-plugin-run.git",
50-
"rollup-plugin-shim": "^1.0.0",
5150
"rollup-plugin-typescript2": "^0.18.1",
5251
"shx": "^0.3.2",
5352
"standard-version": "^4.4.0",
@@ -113,7 +112,7 @@
113112
"postpack": "rm -f oclif.manifest.json",
114113
"posttest": "tslint -p . -t stylish",
115114
"prebuild": "(shx rm -r dist .rpt2_cache types) || true",
116-
"prepack": "rm -rf dist && tsc -b && oclif-dev manifest && oclif-dev readme",
115+
"prepack": "tsc -b && oclif-dev manifest && oclif-dev readme",
117116
"prepublishOnly": "npm run build",
118117
"prestart": "npm run prebuild",
119118
"pretest": "npm run build",

rollup.config.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const configure = ({input, output, watch, ...others}) => ({
4141
input,
4242
output: Object.assign({
4343
format: "cjs",
44-
exports: "default"
44+
exports: "named"
4545
}, output),
4646
experimentalCodeSplitting: true,
4747
watch: {clearScreen: false},
@@ -55,9 +55,6 @@ const configure = ({input, output, watch, ...others}) => ({
5555
readline: resolve("./src/shim-readline")
5656
// 🤔 I'm still uncertain if I need to shim the readline or the stdin/stdout
5757
}),
58-
shim({
59-
os: "export const hostname = () => require('byteballcore/conf.js').deviceName"
60-
}),
6158
babel(),
6259
nodeResolve(),
6360
commonjs({ignore: id => id !== "readline"}),

src/shim-readline.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import conf from 'byteballcore/conf'
12
import {ReadLineOptions} from 'readline'
23

34
import {bot, Question} from './event-handler'
@@ -12,7 +13,10 @@ export function createInterface(_options: ReadLineOptions) {
1213
question(query: string, answering: (response: string | void) => void) {
1314
// #region helpers
1415
query = query.toLocaleLowerCase()
15-
const on = (event: Question) => Promise.resolve(bot.onAsking[event]!())
16+
const on = (event: Question) => {
17+
const cb = bot.onAsking[event]
18+
return Promise.resolve(cb ? cb() : conf.devicename)
19+
}
1620
const questionIncludes = (keywords: string[]) => keywords.every(keyword => query.includes(keyword))
1721
// #endregion helpers
1822

src/shim.d.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ declare module 'headless-byteball' {
1313
export const issueChangeAddressAndSendPayment: Wallet.issueChangeAddressAndSendPayment
1414
}
1515

16-
declare module 'byteballcore/conf' {
17-
export const deviceName: string
18-
}
19-
2016
interface Device {
2117
sendMessageToDevice(
2218
device_address: string,

0 commit comments

Comments
 (0)