function npmCache () { var env = process.env return env.npm_config_cache || (env.APPDATA ? path.join(env.APPDATA, 'npm-cache') : path.join(home(), '.npm')) }
var SavedConnectionManager = function() { this.configPath = path.join(osHomedir(), ".censql", "saved_connections"); this.load(); }
memo('home', function () { return osHomedir() })
// All the keys of past and present participants var keys = [] var argv = minimist(process.argv.slice(2)) if (argv.help) { console.error('Usage: hyperchat [options]') console.error() console.error(' --feed=[feed-key] Feed of one participant') console.error(' --user=[username] Username') console.error() process.exit(1) } var db = level(path.join(home(), '.hyperchat.db')) var core = hypercore(db) var myFeed = core.createFeed() // Set username var cmd = {type: 'username', username: '******'} if (argv.user) { cmd.username = argv.user } myFeed.append(JSON.stringify(cmd)) console.log('my key is ' + myFeed.key.toString('hex')) console.log('my discovery key is ' + myFeed.discoveryKey.toString('hex')) // Share our feed join(myFeed)
} }; function mkdirp ( dir ) { var parent = path.dirname( dir ); if ( dir === parent ) return; mkdirp( parent ); try { fs.mkdirSync( dir ); } catch ( err ) { if ( err.code !== 'EEXIST' ) throw err; } } var home = homedir(); if ( home ) { var cachedir = path.join( home, '.buble-cache', nodeVersion ); mkdirp( cachedir ); fs.writeFileSync( path.join( home, '.buble-cache/README.txt' ), 'These files enable a faster startup when using buble/register. You can safely delete this folder at any time. See https://buble.surge.sh/guide/ for more information.' ); } var optionsStringified = JSON.stringify( options ); require.extensions[ '.js' ] = function ( m, filename ) { if ( nodeModulesPattern.test( filename ) ) return original( m, filename ); var source = fs.readFileSync( filename, 'utf-8' ); var hash = crypto.createHash( 'sha256' ); hash.update( buble.VERSION ); hash.update( optionsStringified );
gulp.task('add-deploy-target', function(done) { log('Update ecosystem.json targets or create new ones!'); var properties = fs.readFileSync('deploy/build.properties', encoding); var name = properties.match(/app-name=(.*)/)[1]; var gitUrl = 'https://github.com/'; var folderPath = '/space/projects/' + name; var osHomedir = require('os-homedir'); var keyPath = osHomedir() + '/.ssh/id_rsa'; var ecosystem = 'ecosystem.json'; ecosystemMustExist(ecosystem, name); $.git.exec({ args: 'config --get remote.origin.url', quiet: true }, function(err, stdout) { if (!err) { gitUrl = stdout.split('\n')[0]; } var questions = [{ type: 'input', name: 'targetName', message: 'What\'s the name of this deployment target? (If this target exists we\'ll replace it!!!!)', default: 'prod' }, { type: 'input', name: 'key', message: 'Where do you keep your ssh key that\'s used for both the target server and the git repository?', default: keyPath }, { type: 'input', name: 'username', message: 'Where\'s your username on the target server?', default: username.sync() }, { type: 'input', name: 'hostname', message: 'What\'s the hostname of the target server?', default: 'localhost' }, { type: 'input', name: 'branch', message: 'Which git branch are we deploying?', default: 'master' }, { type: 'input', name: 'gitUrl', message: 'What\'s the url of your git repository?', default: gitUrl }, { type: 'input', name: 'folder', message: 'Where do you want to store the project on your target server?', default: folderPath }, { type: 'list', name: 'local', message: 'Is there any sensitive information or credentials here that shouldn\'t go in source control?', choices: ['no', 'yes'], default: 0 }]; gulp.src(ecosystem) .pipe($.prompt.prompt(questions, function(answers) { if (answers.local === 'yes') { ecosystem = 'local.ecosystem.json'; ecosystemMustExist(ecosystem, name); } gulp.src(ecosystem) .pipe($.jsonEditor(function(json) { json.deploy[answers.targetName] = { 'key': answers.key, 'user': answers.username, 'host': [answers.hostname], 'ref': 'origin/' + answers.branch, 'repo': answers.gitUrl, 'path': answers.folder, 'post-deploy': 'npm install && bower install && gulp build' }; return json; // must return JSON object. })) .pipe(gulp.dest('./')); })); }); });
const { dirname, basename, join, resolve } = require('path'); const { exists, stat, writeFile, readFile, unlink, readdir } = require('fs'); const { mkdirsSync } = require('fs-extra'); const homedir = require('os-homedir'); const temp = require('temp').track(); const request = require('request'); const wrapProgress = require('request-progress'); const ProgressBar = require('progress'); const Flow = require('node-async-flow'); const DIR_CACHES = join(homedir(), '.nwjs-download', 'caches'); mkdirsSync(DIR_CACHES); const FILE_MANIFEST_CACHE = join(DIR_CACHES, 'manifest.json'); const EXPIRY_MANIFEST_CACHE = 3600000; const GetManifest = (callback) => { const debug = require('debug')('NWD:GetManifest'); Flow(function*(cb) { const cacheExists = yield exists(FILE_MANIFEST_CACHE, cb.single); var useCache = false;
'use strict'; var osHomedir = require('os-homedir'); var home = osHomedir(); module.exports = function (str) { if (typeof str !== 'string') { throw new TypeError('Expected a string'); } return home ? str.replace(/^~($|\/|\\)/, home + '$1') : str; };
timeout: 30, color: false, reporter: 'tap', files: [], bail: false, saveFile: null, pipeToService: false, coverageReport: null, browser: true, coverage: false, checkCoverage: false, branches: 0, functions: 0, lines: 0, statements: 0, rcFile: osHomedir() + '/.taprc' } function runTest (rcFile, expect) { return function (t) { var env = { HOME: process.env.HOME, TAP_TIMEOUT: 30 } if (rcFile) { env.TAP_RCFILE = rcFile expect.rcFile = rcFile } var child = spawn(node, [ run, '--dump-config' ], { env: env })
'use strict'; const osHomedir = require('os-homedir'); const home = osHomedir(); module.exports = str => { if (typeof str !== 'string') { throw new TypeError(`Expected a string, got ${typeof str}`); } return home ? str.replace(/^~($|\/|\\)/, `${home}$1`) : str; };
ScreenManager.prototype.setupInput = function() { if (!process.stdout.isTTY) { process.stdout.on('error', function(err) { if (err.code == "EPIPE") { process.exit(0); } }) return; } process.stdin.pause(); readline.createInterface({ input: process.stdin, output: process.stdout, path: path.join(osHomedir(), ".censql", "censql_hist"), maxLength: 2000, prompt: "NOT SET", next: function(rl) { this.rl = rl; this.rl.on('line', function(line) { if (global.censql.RUNNING_PROCESS) return; /** * Check terminal width */ global.censql.graphWidth = process.stdout.columns; /** * Stop taking user input until we complete this request */ process.stdin.pause(); /** * Save that we already have a running process * @type {Boolean} */ global.censql.RUNNING_PROCESS = true; /** * hide prompt (fixes bug with resizing terminal whilst a command is running) */ this.rl.setPrompt(""); /** * Hide user input whilst a command is running (simply pausing stdin still allows scrolling through history) */ process.stdin._events._keypress_full = process.stdin._events.keypress; process.stdin._events.keypress = function(ch, key) { if (key && key.ctrl && key.name == 'c') { global.censql.SHOULD_EXIT = true; } }; /** * Send the user command to the command handler */ this.commandHandler.handleCommand(line, function(err, output) { if (err) { console.log(err); } this.commandHandler.getActiveSchema(function(err, schema) { if (!err) { /** * Set the active schema * @type {String} */ this.current_schema = schema; } /** * Print the command to the screen however the command handler thinks is best */ this.printCommandOutput(line, output, function() { /** * Re-enable the command line */ process.stdin.resume(); /** * Reset running app state * @type {Boolean} */ global.censql.RUNNING_PROCESS = false; /** * Should the running process exit? * @type {Boolean} */ global.censql.SHOULD_EXIT = false; /** * Reset the keypress function for stdin */ process.stdin._events.keypress = process.stdin._events._keypress_full; }.bind(this)); }.bind(this)); }.bind(this)); }.bind(this)); /** * On close, give the user a pretty message and then stop the entire program */ this.rl.on('close', function() { this.print(colors.green('\n\nThanks for using CenSQL!\n')); this.rl.close(); process.exit(0); }.bind(this)); /** * When the user ^Cs make sure they weren't just trying to clear the command */ this.rl.on('SIGINT', function() { if (global.censql.RUNNING_PROCESS) { global.censql.SHOULD_EXIT = true; return; } charm.erase("line"); charm.left(99999); charm.up(1); /** * Exit command promt */ this.rl.close(); /** * Exit program */ process.exit(0); }.bind(this)); }.bind(this) }); }
var fs = require('fs'), exec = require('child_process').exec, join = require('path').join, basename = require('path').basename, osHomedir = require('os-homedir'); // var daemons_path = '/Library/LaunchDaemons'; var daemons_path = osHomedir() + '/Library/LaunchAgents'; /////////////////////////////////////////// // helpers var debug = !!process.env.DEBUG, log = debug ? console.log : function() { }; var get_path = function(name) { return name.indexOf(daemons_path) === -1 ? join(daemons_path, name + '.plist') : name; } // copies a file var copy = function(source, target, cb) { var is = fs.createReadStream(source), os = fs.createWriteStream(target), out = 0; var done = function(err) { if (out++ > 0) return; cb(err); }; is.on('end', done);
// search for old config options by looping over every key, value pair _.forEach(config, function(value, option) { var newOption = deprecatedOptions[option]; if (newOption) { config[newOption] = value; delete(config[option]); warnDeprecated(option, newOption); } }); return config; }; var config; var configPath = argv.c || path.join(osHomedir(), '.teleirc', 'config.js'); if (argv.g) { mkdirp(path.join(osHomedir(), '/.teleirc')); // read default config using readFile to include comments var config = fs.readFileSync(path.join(__dirname, 'config.defaults.js')); fs.writeFileSync(configPath, config); console.log('Wrote default configuration to ' + configPath + ', please edit it before re-running'); process.exit(0); } else if (argv.j) { require('./join-tg'); process.exit(0); } try {
function itunesFolders() { const linuxWinPath = osHomedir() + "/Music/iTunes/iTunes\ Media"; const macPath = osHomedir() + "/Music/iTunes/iTunes\ Music" return [linuxWinPath, macPath]; }
var needle = require('needle'), crypto = require('crypto'), exit = require('exit'), dotenv = require("dotenv"), osHomedir = require('os-homedir'); // consider replacing with os.homedir() later // mixpanel var base_url = "http://mixpanel.com/api/2.0/"; require('sugar-date'); // add environment variables from .env if present, check (in prio order) // - .env in script directory // - .engagerc in home directory dotenv.load({ silent: true }) || dotenv.load({ silent: true, path: osHomedir() + '/.engagerc' }); // options var yargs = require('yargs') .usage('Usage: $0 -k [string] -s [string]') .options('k', { alias: 'key', describe: 'Mixpanel API key', nargs: 1, type: 'string' }) .options('s', { alias: 'secret', describe: 'Mixpanel API secret', nargs: 1, type: 'string'
setTimeout: setTimeout, global: global }); var content = FileUtils.readFile(file); var script = new vm.Script(content); script.runInContext(context); return; } else { console.error('file specified but doesnt exists ' + commander.file); } } */ } let user = null; if (!argv.user && argv.home === 'true') { user = path.join(homedir(), 'Documents', 'Control-Freak'); } const CFOptions = { root: root, port: argv.port, release: argv.release === 'true', clientRoot: argv.clientRoot, type: argv.type || Base_1.ELayout.SOURCE, print: argv.print === 'true', uuid: argv.uuid || 'ide', user: user || (argv.user ? path.resolve(argv.user) : null), persistence: argv.persistences ? argv.persistence : Application_1.EPersistence.MEMORY, interface: argv.interface ? argv.interface : null, home: argv.home === 'true' }; function create(app) {
module.exports = function (opts) { opts = opts || {} var config = {} config.filename = opts.filename || '.staticlandrc' config.filepath = opts.filepath || path.join(homedir(), config.filename) config.init = function () { if (config.read()) { return } else { config.write({ currentLogin: null, logins: [] }) } } config.read = function () { var file try { file = fs.readFileSync(config.filepath, 'utf8') } catch (err) { // file not found } if (!file || file instanceof Error) return false return JSON.parse(file) } config.write = function (data) { var file = JSON.stringify(data, true, 2) fs.writeFileSync(config.filepath, file) } config.get = function (key) { var data = config.read() if (!key) return data var keys = parseKeys(key) var current = keys[0] if (keys.length === 1) return data[current] } config.set = function (key, value) { var data = config.read() var keys = parseKeys(key) var current = keys[0] if (keys.length === 1) { data[current] = value config.write(data) } } config.getLogin = function (server) { var logins = config.get('logins') if (!server) { return config.get('currentLogin') } var login = logins.find(function (item) { if (item === null) return return item.server === server }) if (!login) return false login.server = server return login } config.setLogin = function (opts) { var logins = config.get('logins') var found = false logins = logins.map(function (login) { if (login === null) return if (login.server === opts.server) { found = true return opts } }) if (!found) { logins.push(opts) } config.set('logins', logins) config.set('currentLogin', opts) } function parseKeys (key) { if (isString(key)) { var keys = key.split('.').map(function (key) { if (isNumber(key)) return parseInt(key) return key }) return keys } return key } return config }
var isWindows=process.platform==="win32";var path=require("path");var exec=require("child_process").exec;var osTmpdir=require("os-tmpdir");var osHomedir=require("os-homedir");function memo(c,d,e){var a=false;var b=false;exports[c]=function(f){var g=d();if(!g&&!a&&!b&&e){a=true;b=true;exec(e,function(j,h,i){b=false;if(j){return}g=h.trim()})}exports[c]=function(h){if(h){process.nextTick(h.bind(null,null,g))}return g};if(f&&!b){process.nextTick(f.bind(null,null,g))}return g}}memo("user",function(){return(isWindows?process.env.USERDOMAIN+"\\"+process.env.USERNAME:process.env.USER)},"whoami");memo("prompt",function(){return isWindows?process.env.PROMPT:process.env.PS1});memo("hostname",function(){return isWindows?process.env.COMPUTERNAME:process.env.HOSTNAME},"hostname");memo("tmpdir",function(){return osTmpdir()});memo("home",function(){return osHomedir()});memo("path",function(){return(process.env.PATH||process.env.Path||process.env.path).split(isWindows?";":":")});memo("editor",function(){return process.env.EDITOR||process.env.VISUAL||(isWindows?"notepad.exe":"vi")});memo("shell",function(){return isWindows?process.env.ComSpec||"cmd":process.env.SHELL||"bash"});
export const parseHome = (str) => { const home = osHomedir(); const includesHomePath = str.split(sep).slice(0, 3).join(sep) === home; return includesHomePath ? str : join(home, str); }