-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
executable file
·45 lines (31 loc) · 1.01 KB
/
index.js
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
#!/usr/bin/env node
const logSymbols = require('log-symbols');
const { readConf } = require('@gh-conf/gh-conf-read');
const { writeConf } = require('@gh-conf/gh-conf-write');
const {
config,
constants
} = require('./lib');
const configure = async (currentPath) => {
try {
// Read config file content
let configContent = await readConf(`${currentPath}`);
// Check if already gitified
const userRegex = new RegExp(constants.user, 'i');
if (userRegex.test(configContent)) {
console.log(logSymbols.info, 'You are already gitified!!!');
return;
}
// Getting user config from /usr/local/.gitifyme/config
const userConfig = await config.get();
configContent = configContent + userConfig
// Writting updated config
await writeConf(`${currentPath}`, configContent);
console.log(logSymbols.success, 'Gitifyed you!!!');
return;
} catch (err) {
console.log(logSymbols.error, err);
}
}
// Triggering flip with current path
configure(process.cwd());