-
Notifications
You must be signed in to change notification settings - Fork 101
/
variables.ts
40 lines (34 loc) 路 1 KB
/
variables.ts
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
import * as process from 'node:process';
import Context from 'fig/Context.js';
/**
* @file
*
* Dynamic variables.
*/
const variables = {
/**
* Because a hostname might have random junk at the end of it (eg.
* "huertas.local" or "retiro.lan") or potentially be mixed case, set
* a variable as a convenient shorthand containing a normalized host
* "handle" (eg. "huertas", "retiro").
*/
get hostHandle() {
const handle = Context.attributes.hostname.toLowerCase().split(/\./)[0];
// Kludgy special-case for Codespaces so that we can cheatingly use per-host
// config files without knowing the exact host name ahead of time.
if (/^codespaces[_-][a-f0-9]+$/.test(handle)) {
return 'codespaces';
}
return handle;
},
get identity() {
if (process.env.FIG_IDENTITY) {
return process.env.FIG_IDENTITY;
} else if (Context.attributes.username === 'wincent') {
return 'wincent';
} else {
return 'unknown';
}
},
};
export default variables;