This commit is contained in:
darenhsu
2022-07-17 13:16:16 +08:00
parent 84759556ff
commit befd344ab0
28070 changed files with 4008428 additions and 1 deletions
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Generated Vendored Executable
+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env node
"use strict";
var fs = require('fs');
global.Fiber = require('../fibers');
global.Future = require('../future');
// Start the repl
var vm = require('vm');
var domain = require('domain');
var repl = require('repl').start('node> ', null, fiberEval, true, true);
function fiberEval(code, context, file, cb) {
if (/^\([ \r\n\t+]\)$/.test(code)) {
return cb(false, undefined);
}
// Parses?
try {
new Function(code);
} catch (err) {
return cb(err, false);
}
// Run in fiber
Future.task(function() {
// Save history
var last;
repl.rli.history = repl.rli.history.slice(0, 50).filter(function(item) {
try {
return item !== last;
} finally {
last = item;
}
});
fs.writeFile(process.env.HOME+ '/.node-history', JSON.stringify(repl.rli.history), function(){});
// Run user code
var d = domain.create();
d.run(function() {
cb(null, vm.runInThisContext(code, file));
});
d.on('error', function(err) {
console.error('\nUnhandled error: '+ err.stack);
});
}).resolve(cb);
}
// Load history
try {
repl.rli.history = JSON.parse(fs.readFileSync(process.env.HOME+ '/.node-history', 'utf-8'));
} catch (err) {}
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.