How to use env-paths - 9 common examples

To help you get started, we’ve selected a few env-paths 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 sw-yx / cli-state / src / index.ts View on Github external
cliId: uuidv4(),
  };
  if (!globalConfOptions.defaults) {
    globalConfOptions = {
      ...globalConfOptions,
      defaults: globalStateDefaults,
    };
  }
  globalState = new Conf.default(globalConfOptions);

  // frecency
  if (globalState instanceof Conf.default) {
    const { _options: options } = globalState as typeof globalState & {
      _options: { projectName: string };
    };
    const storageProviderFrecencyFilePath = envPaths(options.projectName).cache; // store frecency in cache, it is disposable
    if (willPrintDebugMessages) {
      console.log({
        storageProviderFrecencyFilePath,
        globalStatePath: globalState.path,
      });
    }
    const storageProvider = new LocalStorage(storageProviderFrecencyFilePath);
    accessGlobalFrecency = key =>
      new Frecency({
        key,
        storageProvider,
        idAttribute: 'value',
        ...frecencyOpts,
      });
  }
github OpenZeppelin / openzeppelin-sdk / packages / cli / src / telemetry / index.ts View on Github external
async function checkOptIn(interactive: boolean): Promise {
  // disable via env var for local development
  if (module.exports.DISABLE_TELEMETRY) return undefined;

  const project = new ProjectFile();
  const localOptIn = project.telemetryOptIn;

  const { data: globalDataDir } = envPaths('openzeppelin-sdk');
  const globalDataPath = path.join(globalDataDir, 'telemetry.json');
  let globalOptions: GlobalTelemetryOptions | undefined = await fs.readJson(globalDataPath).catch(() => undefined);

  if (localOptIn === false) return undefined;

  // disable interactivity manually for tests and CI
  if (DISABLE_INTERACTIVITY) interactive = false;

  if (globalOptions === undefined && interactive) {
    const { optIn } = await inquirer.prompt({
      name: 'optIn',
      type: 'confirm',
      message:
        'Would you like to contribute anonymous usage data to help us improve the OpenZeppelin CLI? Learn more at https://zpl.in/telemetry',
      default: true,
    });
github Songbee / desktop / src / backend / index.js View on Github external
constructor(debug=false) {
    let isWin = /^win/.test(process.platform);

    let paths = this.paths = { base: envPaths("Songbee", { suffix: "" }) };
    Object.assign(this.paths, {
      downloads: path.join(paths.base.cache, "downloads"),
    });

    this.playlist = [];

    this.webtorrent = new WebTorrent();
    this.player = new MPV({
      audio_only: !debug,
      socket: isWin ? WINDOWS_SOCKET : "/tmp/songbeempv.sock",
      debug: debug,
    });

    this.releases = {};
    this._trackShift = 0;
  }
github ArkEcosystem / core / packages / core-container / src / environment.ts View on Github external
if (values[key]) {
                    const name = `CORE_PATH_${key.toUpperCase()}`;
                    let path = resolve(expandHomeDir(values[key]));

                    if (namespace) {
                        path += `/${this.variables.network}`;
                    }

                    if (process.env[name] === undefined) {
                        process.env[name] = path;
                        ensureDirSync(path);
                    }
                }
            });

        createPathVariables(envPaths(this.variables.token, { suffix: "core" }), this.variables.network);
    }
github ArkEcosystem / core / packages / core / src / commands / command.ts View on Github external
private getEnvPaths(flags: CommandFlags): Paths {
        return envPaths(flags.token, { suffix: "core" });
    }
}
github sqlectron / sqlectron-core / src / utils.js View on Github external
export function getConfigPath() {
  if (configPath) {
    return configPath;
  }

  const configName = 'sqlectron.json';
  const oldConfigPath = path.join(homedir(), `.${configName}`);

  if (fileExistsSync(oldConfigPath)) {
    configPath = oldConfigPath;
  } else {
    const newConfigDir = envPaths('Sqlectron', { suffix: '' }).config;
    configPath = path.join(newConfigDir, configName);
  }

  return configPath;
}
github nikersify / jay / source / cli.ts View on Github external
async function main() {
	const historian = createHistorian(
		path.join(envPaths(packageJson.name).cache, 'history')
	)

	const moduler = createModuler(
		path.join(envPaths(packageJson.name).cache, 'packages')
	)

	const ask = createAsk(
		moduler,
		process.stdin,
		process.stdout
	)

	const {
		context,
		contextIdPromise,
		evaluate,
github neo-one-suite / neo-one / packages / neo-one-server-plugin / src / paths.ts View on Github external
import envPaths from 'env-paths';
import { name } from './name';

export const paths = envPaths(name.cli, { suffix: '' });
github saojs / kopy / lib / Generator.js View on Github external
get cacheFile() {
    if (this.opts.cacheFile) return this.opts.cacheFile
    return require('env-paths')('kopy-cache').config
  }

env-paths

Get paths for storing things like data, config, cache, etc

MIT
Latest version published 3 years ago

Package Health Score

70 / 100
Full package analysis

Popular env-paths functions