-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepl.bootstrap.js
More file actions
58 lines (49 loc) · 1.59 KB
/
repl.bootstrap.js
File metadata and controls
58 lines (49 loc) · 1.59 KB
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
56
57
58
#!/usr/bin/env node --no-warnings --no-deprecations --enable-source-maps
// Import everything for playtesting.
(await import('./src/index.js')).Controls.enableAll();
(await import('./bin/repl.signature.js'))
const {
accessor, data, describe, describeMany, extract, isDescriptor,
isAccessor, isData, redescribe,
} = await import('./src/utils/index.js')
const { inspect } = await import('node:util');
const nejsExtension = await import('@nejs/extension');
const repl = await import('node:repl');
const fs = await import('node:fs');
const { createRepl } = await import('./bin/repl.basics.js')
let replServer = undefined
const help = () =>
`
Welcome to the @nejs/basic-extensions repl bootstrapping process, the
following objects are in scope for you to use. Additionally, all the
extensions and patches included in basic-extensions are enabled and
ready for testing.
${replServer ? replServer.generateStateString() : `
Use the command \x1b[1mstate\x1b[22m to see all variables
exposed to the REPL for testing.
`}
Additionally
.help - See REPL dot commands
info - Show this menu again
state - See the exposed REPL variables again
`
replServer = createRepl({
commands: [
['info', {
action() {
console.log(help());
this?.displayPrompt()
},
help: 'Shows info about defined properties'
}]
],
exports: {
Patch: nejsExtension.Patch,
Extension: nejsExtension.Extension,
accessor, data, describe, describeMany, extract, inspect,
isAccessor, isData, isDescriptor, redescribe,
},
onReady() {
console.log(help())
}
})