functype-os 0.1.0 → 0.2.0
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/dist/config/ConfigResolver.d.ts +14 -4
- package/dist/config/ConfigResolver.js +1 -1
- package/dist/config/ConfigResolver.js.map +1 -1
- package/dist/env/Env.js.map +1 -1
- package/dist/fs/Fs.d.ts +10 -5
- package/dist/fs/Fs.js +1 -1
- package/dist/fs/Fs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/platform/Platform.js +1 -1
- package/package.json +1 -1
|
@@ -1,16 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConfigError } from "../errors/errors.js";
|
|
2
|
+
import { Either, List, Option, TaskResult } from "functype";
|
|
2
3
|
|
|
3
4
|
//#region src/config/ConfigResolver.d.ts
|
|
4
5
|
declare const ConfigResolver: {
|
|
5
6
|
resolve: (options: {
|
|
6
|
-
candidates: readonly string[];
|
|
7
|
+
readonly candidates: readonly string[];
|
|
7
8
|
}) => TaskResult<Option<string>>;
|
|
8
9
|
resolveRequired: (options: {
|
|
9
|
-
candidates: readonly string[];
|
|
10
|
+
readonly candidates: readonly string[];
|
|
10
11
|
}) => TaskResult<string>;
|
|
11
12
|
resolveAll: (options: {
|
|
12
|
-
candidates: readonly string[];
|
|
13
|
+
readonly candidates: readonly string[];
|
|
13
14
|
}) => TaskResult<List<string>>;
|
|
15
|
+
resolveSync: (options: {
|
|
16
|
+
readonly candidates: readonly string[];
|
|
17
|
+
}) => Option<string>;
|
|
18
|
+
resolveRequiredSync: (options: {
|
|
19
|
+
readonly candidates: readonly string[];
|
|
20
|
+
}) => Either<ConfigError, string>;
|
|
21
|
+
resolveAllSync: (options: {
|
|
22
|
+
readonly candidates: readonly string[];
|
|
23
|
+
}) => List<string>;
|
|
14
24
|
};
|
|
15
25
|
//#endregion
|
|
16
26
|
export { ConfigResolver };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ConfigError as e}from"../errors/errors.js";import{Fs as t}from"../fs/Fs.js";import{expandPath as n}from"../path/PathExpander.js";import{Err as r,
|
|
1
|
+
import{ConfigError as e}from"../errors/errors.js";import{Fs as t}from"../fs/Fs.js";import{expandPath as n}from"../path/PathExpander.js";import{Err as r,Left as i,List as a,Ok as o,Option as s,Right as c}from"functype";const l=e=>n(e).fold(()=>s(void 0),e=>s(e)),u={resolve:async e=>{for(let n of e.candidates){let e=l(n);if(e.isNone())continue;let r=await t.exists(e.orThrow());if(!r.isErr()&&r.value)return o(e)}return o(s(void 0))},resolveRequired:async t=>{let n=await u.resolve(t);if(n.isErr())return r(n.error);let i=n.orThrow();return i.isSome()?o(i.orThrow()):r(e(t.candidates))},resolveAll:async e=>{let n=e.candidates.reduce((e,t)=>{let n=l(t);return n.isNone()?e:[...e,n.orThrow()]},[]),r=[];for(let e of n){let n=await t.exists(e);n.isOk()&&n.value&&r.push(e)}return o(a(r))},resolveSync:e=>{for(let n of e.candidates){let e=l(n);if(!e.isNone()&&t.existsSync(e.orThrow()))return e}return s(void 0)},resolveRequiredSync:t=>u.resolveSync(t).fold(()=>i(e(t.candidates)),e=>c(e)),resolveAllSync:e=>a(e.candidates.reduce((e,n)=>{let r=l(n);if(r.isNone())return e;let i=r.orThrow();return t.existsSync(i)?[...e,i]:e},[]))};export{u as ConfigResolver};
|
|
2
2
|
//# sourceMappingURL=ConfigResolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigResolver.js","names":[],"sources":["../../src/config/ConfigResolver.ts"],"sourcesContent":["import type { TaskResult } from \"functype\"\nimport { Err, List, Ok, Option } from \"functype\"\n\nimport { ConfigError } from \"../errors/errors\"\nimport { Fs } from \"../fs/Fs\"\nimport { expandPath } from \"../path/PathExpander\"\n\nconst tryExpandPath = (candidate: string): string
|
|
1
|
+
{"version":3,"file":"ConfigResolver.js","names":["ConfigErrorConstructor"],"sources":["../../src/config/ConfigResolver.ts"],"sourcesContent":["import type { Either, TaskResult } from \"functype\"\nimport { Err, Left, List, Ok, Option, Right } from \"functype\"\n\nimport type { ConfigError } from \"../errors/errors\"\nimport { ConfigError as ConfigErrorConstructor } from \"../errors/errors\"\nimport { Fs } from \"../fs/Fs\"\nimport { expandPath } from \"../path/PathExpander\"\n\nconst tryExpandPath = (candidate: string): Option<string> => {\n const result = expandPath(candidate)\n return result.fold(\n () => Option<string>(undefined),\n (v) => Option(v),\n )\n}\n\nexport const ConfigResolver = {\n // Async methods — return TaskResult<T>\n\n resolve: async (options: { readonly candidates: readonly string[] }): TaskResult<Option<string>> => {\n for (const candidate of options.candidates) {\n const expanded = tryExpandPath(candidate)\n if (expanded.isNone()) continue\n\n const existsResult = await Fs.exists(expanded.orThrow())\n if (existsResult.isErr()) continue\n if (existsResult.value) {\n return Ok(expanded)\n }\n }\n return Ok(Option<string>(undefined))\n },\n\n resolveRequired: async (options: { readonly candidates: readonly string[] }): TaskResult<string> => {\n const result = await ConfigResolver.resolve(options)\n if (result.isErr()) return Err(result.error)\n\n const optValue = result.orThrow()\n if (optValue.isSome()) {\n return Ok(optValue.orThrow())\n }\n\n return Err(ConfigErrorConstructor(options.candidates))\n },\n\n resolveAll: async (options: { readonly candidates: readonly string[] }): TaskResult<List<string>> => {\n const found: readonly string[] = options.candidates.reduce<readonly string[]>((acc, candidate) => {\n const expanded = tryExpandPath(candidate)\n if (expanded.isNone()) return acc\n return [...acc, expanded.orThrow()]\n }, [])\n\n const results: string[] = []\n for (const expanded of found) {\n const existsResult = await Fs.exists(expanded)\n if (existsResult.isOk() && existsResult.value) {\n results.push(expanded)\n }\n }\n\n return Ok(List(results))\n },\n\n // Sync methods — return Either<ConfigError, T>\n\n resolveSync: (options: { readonly candidates: readonly string[] }): Option<string> => {\n for (const candidate of options.candidates) {\n const expanded = tryExpandPath(candidate)\n if (expanded.isNone()) continue\n if (Fs.existsSync(expanded.orThrow())) {\n return expanded\n }\n }\n return Option<string>(undefined)\n },\n\n resolveRequiredSync: (options: { readonly candidates: readonly string[] }): Either<ConfigError, string> => {\n const result = ConfigResolver.resolveSync(options)\n return result.fold(\n () => Left(ConfigErrorConstructor(options.candidates)),\n (v) => Right(v),\n )\n },\n\n resolveAllSync: (options: { readonly candidates: readonly string[] }): List<string> => {\n return List(\n options.candidates.reduce<readonly string[]>((acc, candidate) => {\n const expanded = tryExpandPath(candidate)\n if (expanded.isNone()) return acc\n const path = expanded.orThrow()\n return Fs.existsSync(path) ? [...acc, path] : acc\n }, []),\n )\n },\n}\n"],"mappings":"0NAQA,MAAM,EAAiB,GACN,EAAW,EAAU,CACtB,SACN,EAAe,IAAA,GAAU,CAC9B,GAAM,EAAO,EAAE,CACjB,CAGU,EAAiB,CAG5B,QAAS,KAAO,IAAoF,CAClG,IAAK,IAAM,KAAa,EAAQ,WAAY,CAC1C,IAAM,EAAW,EAAc,EAAU,CACzC,GAAI,EAAS,QAAQ,CAAE,SAEvB,IAAM,EAAe,MAAM,EAAG,OAAO,EAAS,SAAS,CAAC,CACpD,MAAa,OAAO,EACpB,EAAa,MACf,OAAO,EAAG,EAAS,CAGvB,OAAO,EAAG,EAAe,IAAA,GAAU,CAAC,EAGtC,gBAAiB,KAAO,IAA4E,CAClG,IAAM,EAAS,MAAM,EAAe,QAAQ,EAAQ,CACpD,GAAI,EAAO,OAAO,CAAE,OAAO,EAAI,EAAO,MAAM,CAE5C,IAAM,EAAW,EAAO,SAAS,CAKjC,OAJI,EAAS,QAAQ,CACZ,EAAG,EAAS,SAAS,CAAC,CAGxB,EAAIA,EAAuB,EAAQ,WAAW,CAAC,EAGxD,WAAY,KAAO,IAAkF,CACnG,IAAM,EAA2B,EAAQ,WAAW,QAA2B,EAAK,IAAc,CAChG,IAAM,EAAW,EAAc,EAAU,CAEzC,OADI,EAAS,QAAQ,CAAS,EACvB,CAAC,GAAG,EAAK,EAAS,SAAS,CAAC,EAClC,EAAE,CAAC,CAEA,EAAoB,EAAE,CAC5B,IAAK,IAAM,KAAY,EAAO,CAC5B,IAAM,EAAe,MAAM,EAAG,OAAO,EAAS,CAC1C,EAAa,MAAM,EAAI,EAAa,OACtC,EAAQ,KAAK,EAAS,CAI1B,OAAO,EAAG,EAAK,EAAQ,CAAC,EAK1B,YAAc,GAAwE,CACpF,IAAK,IAAM,KAAa,EAAQ,WAAY,CAC1C,IAAM,EAAW,EAAc,EAAU,CACrC,MAAS,QAAQ,EACjB,EAAG,WAAW,EAAS,SAAS,CAAC,CACnC,OAAO,EAGX,OAAO,EAAe,IAAA,GAAU,EAGlC,oBAAsB,GACL,EAAe,YAAY,EAAQ,CACpC,SACN,EAAKA,EAAuB,EAAQ,WAAW,CAAC,CACrD,GAAM,EAAM,EAAE,CAChB,CAGH,eAAiB,GACR,EACL,EAAQ,WAAW,QAA2B,EAAK,IAAc,CAC/D,IAAM,EAAW,EAAc,EAAU,CACzC,GAAI,EAAS,QAAQ,CAAE,OAAO,EAC9B,IAAM,EAAO,EAAS,SAAS,CAC/B,OAAO,EAAG,WAAW,EAAK,CAAG,CAAC,GAAG,EAAK,EAAK,CAAG,GAC7C,EAAE,CAAC,CACP,CAEJ"}
|
package/dist/env/Env.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Env.js","names":[],"sources":["../../src/env/Env.ts"],"sourcesContent":["import type { Either } from \"functype\"\nimport { Left, List, Option, Right } from \"functype\"\n\nimport { EnvError } from \"../errors/errors\"\n\nconst EnvConstructor = (name: string): Option<string> => Option(process.env[name])\n\nconst EnvCompanion = {\n get: (name: string): Option<string> => Option(process.env[name]),\n\n getRequired: (name: string): Either<EnvError, string> => {\n const value = process.env[name]\n return value !== undefined ? Right(value) : Left(EnvError(name))\n },\n\n getOrDefault: (name: string, defaultValue: string): string => process.env[name] ?? defaultValue,\n\n has: (name: string): boolean => process.env[name] !== undefined,\n\n entries: (): List<readonly [string, string]> => {\n const pairs: Array<readonly [string, string]
|
|
1
|
+
{"version":3,"file":"Env.js","names":[],"sources":["../../src/env/Env.ts"],"sourcesContent":["import type { Either } from \"functype\"\nimport { Left, List, Option, Right } from \"functype\"\n\nimport { EnvError } from \"../errors/errors\"\n\nconst EnvConstructor = (name: string): Option<string> => Option(process.env[name])\n\nconst EnvCompanion = {\n get: (name: string): Option<string> => Option(process.env[name]),\n\n getRequired: (name: string): Either<EnvError, string> => {\n const value = process.env[name]\n return value !== undefined ? Right(value) : Left(EnvError(name))\n },\n\n getOrDefault: (name: string, defaultValue: string): string => process.env[name] ?? defaultValue,\n\n has: (name: string): boolean => process.env[name] !== undefined,\n\n entries: (): List<readonly [string, string]> => {\n const pairs: Readonly<Array<readonly [string, string]>> = Object.entries(process.env)\n .filter((entry): entry is [string, string] => entry[1] !== undefined)\n .map(([k, v]) => [k, v] as const)\n return List(pairs)\n },\n}\n\nexport const Env: typeof EnvConstructor & typeof EnvCompanion = Object.assign(EnvConstructor, EnvCompanion)\n"],"mappings":"gHA2BA,MAAa,EAAmD,OAAO,OAtB/C,GAAiC,EAAO,QAAQ,IAAI,GAAM,CAE7D,CACnB,IAAM,GAAiC,EAAO,QAAQ,IAAI,GAAM,CAEhE,YAAc,GAA2C,CACvD,IAAM,EAAQ,QAAQ,IAAI,GAC1B,OAAO,IAAU,IAAA,GAA2B,EAAK,EAAS,EAAK,CAAC,CAAnC,EAAM,EAAM,EAG3C,cAAe,EAAc,IAAiC,QAAQ,IAAI,IAAS,EAEnF,IAAM,GAA0B,QAAQ,IAAI,KAAU,IAAA,GAEtD,YAIS,EAHmD,OAAO,QAAQ,QAAQ,IAAI,CAClF,OAAQ,GAAqC,EAAM,KAAO,IAAA,GAAU,CACpE,KAAK,CAAC,EAAG,KAAO,CAAC,EAAG,EAAE,CAAU,CACjB,CAErB,CAE0G"}
|
package/dist/fs/Fs.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FsError } from "../errors/errors.js";
|
|
2
|
+
import { Either, List, Option, TaskResult } from "functype";
|
|
2
3
|
|
|
3
4
|
//#region src/fs/Fs.d.ts
|
|
4
5
|
declare const Fs: {
|
|
5
|
-
exists: (
|
|
6
|
-
readFile: (
|
|
7
|
-
readFileOpt: (
|
|
8
|
-
readdir: (
|
|
6
|
+
exists: (p: string) => TaskResult<boolean>;
|
|
7
|
+
readFile: (p: string, encoding?: BufferEncoding) => TaskResult<string>;
|
|
8
|
+
readFileOpt: (p: string, encoding?: BufferEncoding) => TaskResult<Option<string>>;
|
|
9
|
+
readdir: (p: string) => TaskResult<List<string>>;
|
|
10
|
+
existsSync: (p: string) => boolean;
|
|
11
|
+
readFileSync: (p: string, encoding?: BufferEncoding) => Either<FsError, string>;
|
|
12
|
+
readFileOptSync: (p: string, encoding?: BufferEncoding) => Either<FsError, Option<string>>;
|
|
13
|
+
readdirSync: (p: string) => Either<FsError, List<string>>;
|
|
9
14
|
};
|
|
10
15
|
//#endregion
|
|
11
16
|
export { Fs };
|
package/dist/fs/Fs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{FsError as e}from"../errors/errors.js";import{Err as t,
|
|
1
|
+
import{FsError as e}from"../errors/errors.js";import{Err as t,Left as n,List as r,Ok as i,Option as a,Right as o}from"functype";import*as s from"node:fs";import*as c from"node:fs/promises";const l=(t,n,r)=>e(t,n,r instanceof Error?r:Error(String(r))),u={exists:async e=>{try{return await c.access(e),i(!0)}catch{return i(!1)}},readFile:async(e,n=`utf8`)=>{try{return i(await c.readFile(e,{encoding:n}))}catch(n){return t(l(e,`readFile`,n))}},readFileOpt:async(e,n=`utf8`)=>{try{return i(a(await c.readFile(e,{encoding:n})))}catch(n){return n instanceof Error&&`code`in n&&n.code===`ENOENT`?i(a(void 0)):t(l(e,`readFile`,n))}},readdir:async e=>{try{return i(r(await c.readdir(e)))}catch(n){return t(l(e,`readdir`,n))}},existsSync:e=>{try{return s.accessSync(e),!0}catch{return!1}},readFileSync:(e,t=`utf8`)=>{try{return o(s.readFileSync(e,{encoding:t}))}catch(t){return n(l(e,`readFileSync`,t))}},readFileOptSync:(e,t=`utf8`)=>{try{return o(a(s.readFileSync(e,{encoding:t})))}catch(t){return t instanceof Error&&`code`in t&&t.code===`ENOENT`?o(a(void 0)):n(l(e,`readFileOptSync`,t))}},readdirSync:e=>{try{return o(r(s.readdirSync(e)))}catch(t){return n(l(e,`readdirSync`,t))}}};export{u as Fs};
|
|
2
2
|
//# sourceMappingURL=Fs.js.map
|
package/dist/fs/Fs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Fs.js","names":[],"sources":["../../src/fs/Fs.ts"],"sourcesContent":["import * as fs from \"node:fs/promises\"\n\nimport type { TaskResult } from \"functype\"\nimport { Err, List, Ok, Option } from \"functype\"\n\nimport { FsError } from \"../errors/errors\"\n\nexport const Fs = {\n exists: async (
|
|
1
|
+
{"version":3,"file":"Fs.js","names":[],"sources":["../../src/fs/Fs.ts"],"sourcesContent":["import * as fsSync from \"node:fs\"\nimport * as fs from \"node:fs/promises\"\n\nimport type { Either, TaskResult } from \"functype\"\nimport { Err, Left, List, Ok, Option, Right } from \"functype\"\n\nimport { FsError } from \"../errors/errors\"\n\nconst toFsError = (p: string, op: string, error: unknown): FsError =>\n FsError(p, op, error instanceof Error ? error : new Error(String(error)))\n\nexport const Fs = {\n // Async methods — return TaskResult<T>\n\n exists: async (p: string): TaskResult<boolean> => {\n try {\n await fs.access(p)\n return Ok(true)\n } catch {\n return Ok(false)\n }\n },\n\n readFile: async (p: string, encoding: BufferEncoding = \"utf8\"): TaskResult<string> => {\n try {\n return Ok(await fs.readFile(p, { encoding }))\n } catch (error) {\n return Err(toFsError(p, \"readFile\", error))\n }\n },\n\n readFileOpt: async (p: string, encoding: BufferEncoding = \"utf8\"): TaskResult<Option<string>> => {\n try {\n return Ok(Option(await fs.readFile(p, { encoding })))\n } catch (error) {\n if (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") {\n return Ok(Option<string>(undefined))\n }\n return Err(toFsError(p, \"readFile\", error))\n }\n },\n\n readdir: async (p: string): TaskResult<List<string>> => {\n try {\n return Ok(List(await fs.readdir(p)))\n } catch (error) {\n return Err(toFsError(p, \"readdir\", error))\n }\n },\n\n // Sync methods — return Either<FsError, T>\n\n existsSync: (p: string): boolean => {\n try {\n fsSync.accessSync(p)\n return true\n } catch {\n return false\n }\n },\n\n readFileSync: (p: string, encoding: BufferEncoding = \"utf8\"): Either<FsError, string> => {\n try {\n return Right(fsSync.readFileSync(p, { encoding }))\n } catch (error) {\n return Left(toFsError(p, \"readFileSync\", error))\n }\n },\n\n readFileOptSync: (p: string, encoding: BufferEncoding = \"utf8\"): Either<FsError, Option<string>> => {\n try {\n return Right(Option(fsSync.readFileSync(p, { encoding })))\n } catch (error) {\n if (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") {\n return Right(Option<string>(undefined))\n }\n return Left(toFsError(p, \"readFileOptSync\", error))\n }\n },\n\n readdirSync: (p: string): Either<FsError, List<string>> => {\n try {\n return Right(List(fsSync.readdirSync(p)))\n } catch (error) {\n return Left(toFsError(p, \"readdirSync\", error))\n }\n },\n}\n"],"mappings":"6LAQA,MAAM,GAAa,EAAW,EAAY,IACxC,EAAQ,EAAG,EAAI,aAAiB,MAAQ,EAAY,MAAM,OAAO,EAAM,CAAC,CAAC,CAE9D,EAAK,CAGhB,OAAQ,KAAO,IAAmC,CAChD,GAAI,CAEF,OADA,MAAM,EAAG,OAAO,EAAE,CACX,EAAG,GAAK,MACT,CACN,OAAO,EAAG,GAAM,GAIpB,SAAU,MAAO,EAAW,EAA2B,SAA+B,CACpF,GAAI,CACF,OAAO,EAAG,MAAM,EAAG,SAAS,EAAG,CAAE,WAAU,CAAC,CAAC,OACtC,EAAO,CACd,OAAO,EAAI,EAAU,EAAG,WAAY,EAAM,CAAC,GAI/C,YAAa,MAAO,EAAW,EAA2B,SAAuC,CAC/F,GAAI,CACF,OAAO,EAAG,EAAO,MAAM,EAAG,SAAS,EAAG,CAAE,WAAU,CAAC,CAAC,CAAC,OAC9C,EAAO,CAId,OAHI,aAAiB,OAAS,SAAU,GAAS,EAAM,OAAS,SACvD,EAAG,EAAe,IAAA,GAAU,CAAC,CAE/B,EAAI,EAAU,EAAG,WAAY,EAAM,CAAC,GAI/C,QAAS,KAAO,IAAwC,CACtD,GAAI,CACF,OAAO,EAAG,EAAK,MAAM,EAAG,QAAQ,EAAE,CAAC,CAAC,OAC7B,EAAO,CACd,OAAO,EAAI,EAAU,EAAG,UAAW,EAAM,CAAC,GAM9C,WAAa,GAAuB,CAClC,GAAI,CAEF,OADA,EAAO,WAAW,EAAE,CACb,QACD,CACN,MAAO,KAIX,cAAe,EAAW,EAA2B,SAAoC,CACvF,GAAI,CACF,OAAO,EAAM,EAAO,aAAa,EAAG,CAAE,WAAU,CAAC,CAAC,OAC3C,EAAO,CACd,OAAO,EAAK,EAAU,EAAG,eAAgB,EAAM,CAAC,GAIpD,iBAAkB,EAAW,EAA2B,SAA4C,CAClG,GAAI,CACF,OAAO,EAAM,EAAO,EAAO,aAAa,EAAG,CAAE,WAAU,CAAC,CAAC,CAAC,OACnD,EAAO,CAId,OAHI,aAAiB,OAAS,SAAU,GAAS,EAAM,OAAS,SACvD,EAAM,EAAe,IAAA,GAAU,CAAC,CAElC,EAAK,EAAU,EAAG,kBAAmB,EAAM,CAAC,GAIvD,YAAc,GAA6C,CACzD,GAAI,CACF,OAAO,EAAM,EAAK,EAAO,YAAY,EAAE,CAAC,CAAC,OAClC,EAAO,CACd,OAAO,EAAK,EAAU,EAAG,cAAe,EAAM,CAAC,GAGpD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ConfigResolver } from "./config/ConfigResolver.js";
|
|
2
1
|
import { ConfigError, EnvError, FsError, OsError, PathError } from "./errors/errors.js";
|
|
2
|
+
import { ConfigResolver } from "./config/ConfigResolver.js";
|
|
3
3
|
import { Env } from "./env/Env.js";
|
|
4
4
|
import { Fs } from "./fs/Fs.js";
|
|
5
5
|
import { Path, expandPath, expandTilde, expandVars } from "./path/PathExpander.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Option as e}from"functype";import*as t from"node:
|
|
1
|
+
import{Option as e}from"functype";import*as t from"node:fs";import*as n from"node:os";import*as r from"node:path";const i=()=>{try{return t.statSync(`/.dockerenv`),!0}catch{return!1}},a=()=>{try{return t.readFileSync(`/proc/self/cgroup`,`utf8`).includes(`docker`)}catch{return!1}},o=e=>{let t={};return()=>(`value`in t||(t.value=e()),t.value)},s=o(()=>i()||a()),c=o(()=>{try{return t.readFileSync(`/proc/self/cgroup`,`utf8`).includes(`kube`)}catch{return!1}}),l=o(()=>{try{let e=t.readFileSync(`/proc/version`,`utf8`);return e.includes(`Microsoft`)||e.includes(`WSL`)}catch{return!1}}),u=o(()=>process.env.CI!==void 0||process.env.GITHUB_ACTIONS!==void 0||process.env.GITLAB_CI!==void 0||process.env.CIRCLECI!==void 0||process.env.JENKINS_URL!==void 0||process.env.TRAVIS!==void 0||process.env.BUILDKITE!==void 0),d={os:()=>process.platform,arch:()=>process.arch,homeDir:()=>n.homedir(),tmpDir:()=>n.tmpdir(),hostname:()=>n.hostname(),eol:()=>n.EOL,pathSep:()=>r.sep,isWindows:()=>process.platform===`win32`,isMac:()=>process.platform===`darwin`,isLinux:()=>process.platform===`linux`,userInfo:()=>{try{let t=n.userInfo();return e({username:t.username,uid:t.uid,gid:t.gid,shell:t.shell,homedir:t.homedir})}catch{return e(void 0)}},isDocker:()=>s(),isKubernetes:()=>c(),isWSL:()=>l(),isCI:()=>u(),isContainer:()=>d.isDocker()||d.isKubernetes()};export{d as Platform};
|
|
2
2
|
//# sourceMappingURL=Platform.js.map
|