1 |
|
2 | (function() {
|
3 | var fs, mkdirp, save, yaml;
|
4 |
|
5 | fs = require('fs');
|
6 |
|
7 | mkdirp = require('mkdirp');
|
8 |
|
9 | yaml = require('js-yaml');
|
10 |
|
11 | save = function(opts) {
|
12 | var config;
|
13 | if (opts == null) {
|
14 | opts = {};
|
15 | }
|
16 | if (!fs.existsSync(this.path + "/.autocode")) {
|
17 | mkdirp.sync(this.path + "/.autocode");
|
18 | }
|
19 | config = JSON.parse(JSON.stringify(opts.config || this.config));
|
20 | if (config.host === 'github.com') {
|
21 | delete config.host;
|
22 | }
|
23 | delete config.path;
|
24 | config = yaml.safeDump(config);
|
25 | return fs.writeFileSync(this.path + "/.autocode/config.yml", config);
|
26 | };
|
27 |
|
28 | module.exports = save;
|
29 |
|
30 | }).call(this);
|