How to use configstore - 10 common examples

To help you get started, we’ve selected a few configstore 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 morkro / atom-emoji-syntax / lib / helpers / get-all-languages.js View on Github external
'use babel';

// System
import ConfigStore from 'configstore';
// Defaults
import javascript from '../languages/javascript';
import php from '../languages/php';
import css from '../languages/css';
import scss from '../languages/scss';
import python from '../languages/python';

const jsConf = new ConfigStore(javascript.languageName, javascript);
const phpConf = new ConfigStore(php.languageName, php);
const cssConf = new ConfigStore(css.languageName, css);
const scssConf = new ConfigStore(scss.languageName, scss);
const pythonConf = new ConfigStore(python.languageName, python);
const languages = {
	javascript: jsConf,
	php: phpConf,
	css: cssConf,
	scss: scssConf,
	python: pythonConf
};

/**
 * Takes the package config and returns all enabled languages as array.
 *
 * @param {Boolean} filter
 * @return {Array} List of all enabled languages
 */
export function getAllLanguages (filter) {
github morkro / atom-emoji-syntax / lib / helpers / get-all-languages.js View on Github external
'use babel';

// System
import ConfigStore from 'configstore';
// Defaults
import javascript from '../languages/javascript';
import php from '../languages/php';
import css from '../languages/css';
import scss from '../languages/scss';
import python from '../languages/python';

const jsConf = new ConfigStore(javascript.languageName, javascript);
const phpConf = new ConfigStore(php.languageName, php);
const cssConf = new ConfigStore(css.languageName, css);
const scssConf = new ConfigStore(scss.languageName, scss);
const pythonConf = new ConfigStore(python.languageName, python);
const languages = {
	javascript: jsConf,
	php: phpConf,
	css: cssConf,
	scss: scssConf,
	python: pythonConf
};

/**
 * Takes the package config and returns all enabled languages as array.
 *
 * @param {Boolean} filter
 * @return {Array} List of all enabled languages
 */
github morkro / atom-emoji-syntax / lib / language-data.js View on Github external
return new Promise((resolve) => {
    const { name, internalSettings, userSettings } = languageSettings[lang]
    const filename = `${DEFAULT_SETTINGS_PATH}-${name.toLowerCase()}`

    languageStore[lang] = {
      name,
      internalSettings,
      userSettings: new ConfigStore(filename, userSettings)
    }

    // This is needed because I've updated the language settings logic.
    // I changed a couple of things, but don't want to leave the users without their
    // previous settings. So I check if there are any, copy them over, and eventually
    // delete the old settings file.
    // This approach also feels very ugly. Please send me a note, a PR, or anything to
    // help me improve this part.
    const settingsLocation = languageStore[lang].userSettings.path.replace(filename, name)

    fs.readFile(settingsLocation, 'utf8', (readError, data) => {
      if (readError) return resolve()

      languageStore[lang].userSettings.all = cleanOldSettings(JSON.parse(data))
      fs.unlink(settingsLocation)
github danibram / time-tracker-cli / src / exports.js View on Github external
import Manager from './core/Manager'
import Configstore from 'configstore'

import pkg from '../package.json'

const config = new Configstore(pkg.name, {
    tasks: {},
    config: {
        'format.output': 'DD/MM'
    }
})

export default () => {
    return new Manager(config)
}
github ewnd9 / record-desktop / src / main / config.js View on Github external
import EventEmitter from 'events';
export const eventEmitter = new EventEmitter();

import Configstore from 'configstore';

const conf = new Configstore('record-desktop', { isFirstRun: true });
export const path = conf.path;

export const getFolder = () => conf.get('folder');
export const setFolder = folder => conf.set('folder', folder);

export const getCombo = action => conf.get(`combo-${action}`);
export const setCombo = (action, combo) => conf.set(`combo-${action}`, combo);

export const getScreenshotEffect = () => conf.get('screenshot-effect');
export const setScreenshotEffect = value => conf.set('screenshot-effect', value);

export const getHasNotifications = () => conf.get('has-notifications');
export const setHasNotifications = value => {
  if (typeof value !== 'boolean') {
    throw new Error('value should be type of boolean');
  }
github jwu910 / check-it-out / src / utils / git.js View on Github external
import chalk from 'chalk';
import Configstore from 'configstore';
import path from 'path';
import { spawn } from 'child_process';

/**
 * @typedef {import('../app').Ref} Ref
 * @typedef {import('../app').Remote} Remote
 */

const pkg = require(path.resolve(__dirname, '../../package.json'));

const conf = new Configstore(pkg.name);

let gitResponse;

/**
 * Kill the most recently created child process
 * Used to force exit from loading box
 */
export const closeGitResponse = () => {
  gitResponse.kill();
};

/**
 * Get references and parse through data to build branch array and remote list
 *
 * @returns {Promise} payload and uniqueRemotes
 */
github vtex / toolbelt / src / conf.js View on Github external
import Configstore from 'configstore'
import pkg from '../package.json'

const conf = new Configstore(pkg.name)

const overrides = {}

export function saveAccount (account) {
  conf.set('account', account)
}

export function saveLogin (login) {
  conf.set('login', login)
}

export function saveToken (token) {
  conf.set('token', token)
}

export function saveWorkspace (workspace = 'master') {
github lukasmartinelli / postgis-editor / src / toolbar.js View on Github external
import React from 'react';
import ReactDOM from 'react-dom';
import Modal from 'react-modal';
import * as _ from 'lodash';
import Configstore from 'configstore';
import pkg from '../package.json';

const conf = new Configstore(pkg.name);

export class Toolbar extends React.Component {
    constructor(props) {
        super(props);
		this.runQuery = this.runQuery.bind(this);
		this.saveConnection = this.saveConnection.bind(this);
		this.showEditConnectionModal = this.showEditConnectionModal.bind(this);
		this.closeEditConnectionModal = this.closeEditConnectionModal.bind(this);

		this.hostChanged = this.hostChanged.bind(this);
		this.portChanged = this.portChanged.bind(this);
		this.userChanged = this.userChanged.bind(this);
		this.passwordChanged = this.passwordChanged.bind(this);
		this.dbChanged = this.dbChanged.bind(this);

		this.state = {
github trufflesuite / truffle / packages / config / src / index.ts View on Github external
public static getUserConfig(): Configstore {
    return new Configstore("truffle", {}, { globalConfigPath: true });
  }

configstore

Easily load and save config without having to think about where and how

BSD-2-Clause
Latest version published 3 months ago

Package Health Score

86 / 100
Full package analysis

Popular configstore functions