Blame view

node_modules/bower/lib/node_modules/configstore/readme.md 2.1 KB
2dda2e10   Administrator   generator ignore
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
  # configstore [![Build Status](https://secure.travis-ci.org/yeoman/configstore.svg?branch=master)](http://travis-ci.org/yeoman/configstore)
  
  > Easily load and persist config without having to think about where and how
  
  Config is stored in a JSON file located in `$XDG_CONFIG_HOME` or `~/.config`.<br>
  Example: `~/.config/configstore/some-id.json`
  
  
  ## Usage
  
  ```js
  const Configstore = require('configstore');
  const pkg = require('./package.json');
  
  // Init a Configstore instance with an unique ID e.g.
  // package name and optionally some default values
  const conf = new Configstore(pkg.name, {foo: 'bar'});
  
  conf.set('awesome', true);
  
  console.log(conf.get('awesome'));
  //=> true
  
  console.log(conf.get('foo'));
  //=> bar
  
  conf.set('bar.baz', true);
  
  console.log(conf.get('bar'));
  //=> { baz: true }
  
  console.log(conf.all);
  //=> { foo: 'bar', awesome: true, bar: { baz: true } }
  
  conf.del('awesome');
  
  console.log(conf.get('awesome'));
  //=> undefined
  ```
  
  
  ## API
  
  ### Configstore(packageName, [defaults], [options])
  
  Create a new Configstore instance `config`.
  
  #### packageName
  
  Type: `string`
  
  Name of your package.
  
  #### defaults
  
  Type: `object`
  
  Default content to init the config store with.
  
  #### options
  
  Type: `object`
  
  ##### globalConfigPath
  
  Type: `boolean`<br>
  Default: `false`
  
  Store the config at `$CONFIG/package-name/config.json` instead of the default `$CONFIG/configstore/package-name.json`. This is not recommended as you might end up conflicting with other tools, rendering the "without having to think" idea moot.
  
  ### config.set(key, value)
  
  Set an item.
  
  ### config.set(object)
  
  Set multiple items at once.
  
  ### config.get(key)
  
  Get an item.
  
  ### config.del(key)
  
  Delete an item.
  
  ### config.clear()
  
  Delete all items.
  
  ### config.all
  
  Get all items as an object or replace the current config with an object:
  
  ```js
  conf.all = {
  	hello: 'world'
  };
  ```
  
  ### config.size
  
  Get the item count.
  
  ### config.path
  
  Get the path to the config file. Can be used to show the user where the config file is located or even better open it for them.
  
  
  ## License
  
  [BSD license](http://opensource.org/licenses/bsd-license.php)<br>
  Copyright Google