-
Notifications
You must be signed in to change notification settings - Fork 8
/
nodemodify.sh
executable file
·61 lines (50 loc) · 1022 Bytes
/
nodemodify.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
56
57
58
59
60
#!/bin/bash
# This goofy script attempts to generate a Node module based on the
# Javascript sources in 'js/'.
#
# Uses https://www.npmjs.com/package/safe-eval.
#
# After running this script, try
#
# sudo npm link node-littlesheens
#
# Then
#
# const SHEENS = require('littlesheens');
#
set -e
TARGET=node-littlesheens
mkdir -p $TARGET
cat<<EOF > $TARGET/index.js
function print(x) {
console.log(x);
}
var safeEval = require('safe-eval');
var sandbox = function(code) {
return safeEval(code);
}
EOF
for F in prof match sandbox step; do
cat js/$F.js >> $TARGET/index.js
done
cat<<EOF >> $TARGET/index.js
exports.step = step;
exports.walk = walk;
exports.match = match;
exports.action = sandboxedAction;
exports.times = Times;
EOF
cat<<EOF > $TARGET/package.json
{
"name": "littlesheens",
"version": "1.0.0",
"description": "Little Sheens",
"main": "index.js",
"scripts": {
"test": "echo \"Everything is perfect\""
},
"author": "",
"license": "ISC"
}
EOF
echo "Wrote $TARGET"