MCPcopy Create free account
hub / github.com/chavyleung/scripts /

Class

Env.js:44–909  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42 }
43
44 return new (class {
45 constructor(name, opts) {
46 this.logLevels = { debug: 0, info: 1, warn: 2, error: 3 }
47 this.logLevelPrefixs = {
48 debug: '[DEBUG] ',
49 info: '[INFO] ',
50 warn: '[WARN] ',
51 error: '[ERROR] '
52 }
53 this.logLevel = 'info'
54 this.name = name
55 this.http = new Http(this)
56 this.data = null
57 this.dataFile = 'box.dat'
58 this.logs = []
59 this.isMute = false
60 this.isNeedRewrite = false
61 this.logSeparator = '\n'
62 this.encoding = 'utf-8'
63 this.startTime = new Date().getTime()
64 Object.assign(this, opts)
65 this.log('', `🔔${this.name}, 开始!`)
66 }
67
68 getEnv() {
69 if ('undefined' !== typeof Egern) return 'Egern'
70 if ('undefined' !== typeof $environment && $environment['surge-version'])
71 return 'Surge'
72 if ('undefined' !== typeof $environment && $environment['stash-version'])
73 return 'Stash'
74 if ('undefined' !== typeof module && !!module.exports) return 'Node.js'
75 if ('undefined' !== typeof $task) return 'Quantumult X'
76 if ('undefined' !== typeof $loon) return 'Loon'
77 if ('undefined' !== typeof $rocket) return 'Shadowrocket'
78 }
79
80 isNode() {
81 return 'Node.js' === this.getEnv()
82 }
83
84 isQuanX() {
85 return 'Quantumult X' === this.getEnv()
86 }
87
88 isSurge() {
89 return 'Surge' === this.getEnv()
90 }
91
92 isLoon() {
93 return 'Loon' === this.getEnv()
94 }
95
96 isShadowrocket() {
97 return 'Shadowrocket' === this.getEnv()
98 }
99
100 isStash() {
101 return 'Stash' === this.getEnv()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected