How to use the os.homedir function in os

To help you get started, we’ve selected a few os examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Nike-Inc / aws-thin-s3-node / test / index.int.js View on Github external
'use strict'

const co = require('co')
const test = require('blue-tape')
const s3 = require('../lib/s3')
let path = require('path')

const testBucket = 'web-assets.niketech.com'

var log = (...args) => console.log(...args.map(a => require('util').inspect(a, { colors: true, depth: 1 }))) // eslint-disable-line

// Load AWS secrets
let credentialsContents = require('fs').readFileSync(path.join(require('os').homedir(), '.aws', 'credentials')).toString()
let creds = credentialsContents.split('\n').slice(1, 3)
process.env.AWS_ACCESS_KEY = creds[0].split('= ')[1]
process.env.AWS_SECRET_KEY = creds[1].split('= ')[1]
// log('creds', process.env.AWS_ACCESS_KEY, process.env.AWS_SECRET_KEY)

let testFile = require('fs').readFileSync(path.join(__dirname, '../', 'package.json'))

let testLogger = {
  log: log,
  // debug: log,
  error: log,
  warn: log,
  info: log
}

test('client should be able to upload, read, and delete a file', t => {
github youzan / zan-proxy / src / core / App / services / appInfo.ts View on Github external
constructor(single = true) {
    super();
    // 用户home目录
    const userHome = os.homedir();
    // proxy data存放目录
    this.proxyDataDir = path.join(userHome, '.front-end-proxy');
    // app信息
    this.appInfo = {
      pcIp: ip.address(),
      proxyPort: 8001,
      realUiPort: 40001,
      single,
    };

    this.appDir = global.__root;
  }
github yitzchak / dicy / packages / core / src / State.ts View on Github external
function getConfigHome (): string {
  // Even though Windows and MacOS do not follow the XDG Base Directory spec we
  // allow the environment variable XDG_CONFIG_HOME to override the platform's
  // default in case users want to maintain a consistent configuration setup
  // across multiple platforms.
  switch (process.platform) {
    case 'win32':
      return process.env.XDG_CONFIG_HOME || process.env.APPDATA ||
        path.join(os.homedir(), 'AppData', 'Roaming')
    case 'darwin':
      return process.env.XDG_CONFIG_HOME ||
        path.join(os.homedir(), 'Library', 'Application Support')
    default:
      return process.env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config')
  }
}
github jamesshore / lets_code_javascript / node_modules / shelljs / src / common.js View on Github external
function getUserHome() {
  var result;
  if (os.homedir) {
    result = os.homedir(); // node 3+
  } else {
    result = process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'];
  }
  return result;
}
exports.getUserHome = getUserHome;
github QTGate / QTGate-Desktop-Client / app / imap.js View on Github external
const Net = require("net");
const Tls = require("tls");
const Stream = require("stream");
const Event = require("events");
const Uuid = require("node-uuid");
const Async = require("async");
const Crypto = require("crypto");
const path_1 = require("path");
const os_1 = require("os");
const timers_1 = require("timers");
const buffer_1 = require("buffer");
const Fs = require("fs");
const Upload = require("./uploadFile");
const MAX_INT = 9007199254740992;
const debug = true;
const QTGateFolder = path_1.join(os_1.homedir(), '.QTGate');
const ErrorLogFile = path_1.join(QTGateFolder, 'imap.log');
const ErrorLogFileStream = path_1.join(QTGateFolder, 'imapStream.log');
let flag = 'w';
const saveLog = (log) => {
    const Fs = require('fs');
    const data = `${new Date().toUTCString()}: ${log}\r\n`;
    Fs.appendFile(ErrorLogFile, data, { flag: flag }, err => {
        flag = 'a';
    });
};
const debugOut = (text, isIn) => {
    const log = `【${new Date().toISOString()}${isIn ? '<=' : '=>'}${text}】`;
    saveLog(log);
};
const idleInterval = 1000 * 60; // 3 mins
const noopInterval = 1000;
github pacocoursey / Opus / src / main.js View on Github external
const { app, BrowserWindow } = require('electron');
const ipc = require('electron-better-ipc');
const path = require('path');
const home = require('os').homedir();
const fs = require('fs-extra');
const {
  openWindow,
  getActiveWindows,
  closeIntroWindow,
  createIntroWindow,
  closeSplashWindow,
  createSplashWindow,
  createEditorWindow,
} = require('./helpers');

// Set app image path for dialogs
app.image = path.join(__dirname, '../assets/icon.png');

// Catch unhandled promise rejections
require('electron-unhandled')();
github roblox-ts / roblox-ts / src / analytics.ts View on Github external
async function getStorage() {
	if (!storageInitialized) {
		await _storage.init({
			dir: path.join(os.homedir(), ".roblox-ts"),
		});
		storageInitialized = true;
	}
	return _storage;
}
github treenotation / jtree / products / commandLineApp.node.js View on Github external
_getLogFilePath() {
    return homedir() + "/history.ssv"
  }
  programs(grammarName) {
github runtools / run / core / src / resource / index.js View on Github external
import {validateResourceDescription} from '@resdir/resource-description';
import ResourceFetcher from '@resdir/resource-fetcher';
import {
  shiftPositionalArguments,
  isParsedExpression,
  matchExpression,
  takeArgument
} from '@resdir/expression';
import {createClientError} from '@resdir/error';
import decache from 'decache';

import Runtime from '../runtime';
import RemoteResource from './remote';

const RUN_CLIENT_ID = process.env.RUN_CLIENT_ID || 'RUN_CLI';
const RUN_CLIENT_DIRECTORY = process.env.RUN_CLIENT_DIRECTORY || join(homedir(), '.run');
const RUN_LOCAL_RESOURCES = process.env.RUN_LOCAL_RESOURCES;

const RESDIR_REGISTRY_CLIENT = process.env.RESDIR_REGISTRY_CLIENT || 'resdir/registry-client';
const RESDIR_REGISTRY_SERVER = process.env.RESDIR_REGISTRY_SERVER || 'https://registry.resdir.com';
const RESDIR_UPLOAD_SERVER_S3_BUCKET_NAME =
  process.env.RESDIR_UPLOAD_SERVER_S3_BUCKET_NAME || 'resdir-registry-prod-v1';
const RESDIR_UPLOAD_SERVER_S3_KEY_PREFIX =
  process.env.RESDIR_UPLOAD_SERVER_S3_KEY_PREFIX || 'resources/uploads/';

const RESOURCE_FILE_NAME = '@resource';
const PRIVATE_RESOURCE_SUFFIX = '.private';
const RESOURCE_FILE_FORMATS = ['json', 'json5', 'yaml', 'yml'];
const DEFAULT_RESOURCE_FILE_FORMAT = 'json';

const BOOTSTRAPPING_RESOURCES = [
  'js/resource',