vvauth 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +23 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -5,7 +5,7 @@ const os = require('os');
|
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const path = require('path');
|
|
7
7
|
const url = require('url');
|
|
8
|
-
const {spawn} = require('child_process');
|
|
8
|
+
const {spawn, execFileSync} = require('child_process');
|
|
9
9
|
const passthru = require('nyks/child_process/passthru');
|
|
10
10
|
const wait = require('nyks/child_process/wait');
|
|
11
11
|
|
|
@@ -61,7 +61,28 @@ class vvauth {
|
|
|
61
61
|
let vauth_rc = VAUTH_RC.filter(path => path && fs.existsSync(path))[0];
|
|
62
62
|
if(vauth_rc) {
|
|
63
63
|
let body = fs.readFileSync(vauth_rc, 'utf8');
|
|
64
|
-
|
|
64
|
+
let rc = parse(body);
|
|
65
|
+
let env = process.env;
|
|
66
|
+
|
|
67
|
+
if(get(rc, 'env.gitlab') && !env.CI) {
|
|
68
|
+
try {
|
|
69
|
+
let remote_url = String(execFileSync('git', ['remote', 'get-url', 'origin'], {cwd : path.dirname(vauth_rc), stdio : ['ignore', 'pipe', 'ignore']})).trim();
|
|
70
|
+
let match = remote_url.match(/^[^@]+@[^:]+:(.+)$/);
|
|
71
|
+
let CI_PROJECT_PATH = match ? match[1] : trim(new URL(remote_url).pathname, '/');
|
|
72
|
+
CI_PROJECT_PATH = trim(CI_PROJECT_PATH, '/').replace(/\.git$/, '');
|
|
73
|
+
|
|
74
|
+
if(CI_PROJECT_PATH) {
|
|
75
|
+
let parts = CI_PROJECT_PATH.split('/');
|
|
76
|
+
let CI_PROJECT_NAME = parts.pop();
|
|
77
|
+
let CI_PROJECT_NAMESPACE = parts.join('/');
|
|
78
|
+
let CI_PROJECT_PATH_SLUG = String(CI_PROJECT_PATH).toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
|
|
79
|
+
|
|
80
|
+
env = {...env, CI_PROJECT_PATH, CI_PROJECT_NAME, CI_PROJECT_NAMESPACE, CI_PROJECT_PATH_SLUG};
|
|
81
|
+
}
|
|
82
|
+
} catch(err) {}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
this.rc = walk(rc, v => replaceEnv(v, {env}));
|
|
65
86
|
}
|
|
66
87
|
|
|
67
88
|
this.VAULT_ADDR = this.rc.vault_addr;
|