synsci 2.0.2-test.65.1 → 2.0.2-test.67.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/bin/synsci.mjs +16 -3
- package/package.json +1 -1
package/bin/synsci.mjs
CHANGED
|
@@ -199,9 +199,22 @@ function hasDeprecatedCli() {
|
|
|
199
199
|
function isConnected() {
|
|
200
200
|
const explicit = process.env.OPENSCIENCE_DATA_DIR?.trim()
|
|
201
201
|
const xdgData = process.env.XDG_DATA_HOME || join(homedir(), ".local", "share")
|
|
202
|
-
const
|
|
203
|
-
const
|
|
204
|
-
|
|
202
|
+
const xdgConfig = process.env.XDG_CONFIG_HOME || join(homedir(), ".config")
|
|
203
|
+
const pointerPath = join(xdgConfig, "openscience", "data-location")
|
|
204
|
+
const pointer = (() => {
|
|
205
|
+
try {
|
|
206
|
+
return readFileSync(pointerPath, "utf-8").trim()
|
|
207
|
+
} catch {
|
|
208
|
+
return ""
|
|
209
|
+
}
|
|
210
|
+
})()
|
|
211
|
+
const roots = explicit
|
|
212
|
+
? [resolve(explicit)]
|
|
213
|
+
: pointer
|
|
214
|
+
? [resolve(pointer)]
|
|
215
|
+
: [join(homedir(), ".openscience"), join(xdgData, "openscience")]
|
|
216
|
+
const sessionPath = roots.map((root) => join(root, "openscience-session.json")).find(existsSync)
|
|
217
|
+
if (!sessionPath) return false
|
|
205
218
|
try {
|
|
206
219
|
const data = JSON.parse(readFileSync(sessionPath, "utf-8"))
|
|
207
220
|
if (!data.access_token || !data.expires_at) return false
|
package/package.json
CHANGED