| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -116,21 +116,70 @@ | |
|
|
||
| // If -i or --interactive were passed, or stdin is a TTY. | ||
| if (process._forceRepl || NativeModule.require('tty').isatty(0)) { | ||
| var history; | ||
| var path = NativeModule.require('path'); | ||
| var fs = NativeModule.require('fs'); | ||
| // This code comes from Sindre Sorhus `user-home` module | ||
| // https://github.com/sindresorhus/user-home | ||
| var home = (function getUserHome() { | ||
| var env = process.env; | ||
| var home = env.HOME; | ||
| var user = env.LOGNAME || env.USER || env.LNAME || env.USERNAME; | ||
|
|
||
| if (process.platform === 'win32') { | ||
| return env.USERPROFILE || env.HOMEDRIVE + env.HOMEPATH || home || null; | ||
| } else if (process.platform === 'darwin') { | ||
| return home || (user ? '/Users/' + user : null); | ||
| } else if (process.platform === 'linux') { | ||
| return home || | ||
| (user ? (process.getuid() === 0 ? '/root' : '/home/' + user) : null); | ||
| } | ||
| return home || null; | ||
| })() | ||
| var HISTORY_PATH = home ? path.join(home,'.iojs_history') : null; | ||
|
|
||
| // REPL | ||
| var opts = { | ||
| useGlobal: true, | ||
| ignoreUndefined: false | ||
| }; | ||
|
|
||
| // If we got user-home dir | ||
| if(HISTORY_PATH) { | ||
|
Comment thread
Outdated
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualitystyle: space after if
Sorry, something went wrong.
All reactions
|
||
| // Get history if exist | ||
| try { | ||
| history = fs.readFileSync(HISTORY_PATH, 'utf8') | ||
| .replace(/\n$/, '') // Ignore the last \n | ||
| .split('\n'); | ||
| } catch(e) { | ||
| history = []; | ||
| } | ||
| opts.history = history; | ||
| } | ||
|
|
||
| if (parseInt(process.env['NODE_NO_READLINE'], 10)) { | ||
| opts.terminal = false; | ||
| } | ||
| if (parseInt(process.env['NODE_DISABLE_COLORS'], 10)) { | ||
| opts.useColors = false; | ||
| } | ||
| var repl = Module.requireRepl().start(opts); | ||
| repl.on('exit', function() { | ||
| process.exit(); | ||
| }); | ||
| repl | ||
| .on('line', function(line) { | ||
| if(HISTORY_PATH) | ||
| try { | ||
| fs.appendFileSync(HISTORY_PATH, line + '\n'); | ||
| } catch(e) {} | ||
| }) | ||
| .on('exit', function() { | ||
| if(HISTORY_PATH && repl.history) | ||
| try { | ||
| fs.writeFileSync(HISTORY_PATH, repl.history | ||
| .join('\n')); | ||
| } catch(e) {} | ||
|
|
||
| process.exit(); | ||
| }); | ||
|
|
||
| } else { | ||
| // Read all of stdin - execute it. | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualitystyle: missing semicolon here
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.