@socketsecurity/lib 1.3.4 → 2.0.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/CHANGELOG.md +103 -0
- package/dist/agent.js +1 -1
- package/dist/agent.js.map +2 -2
- package/dist/bin.js +1 -1
- package/dist/bin.js.map +3 -3
- package/dist/cacache.d.ts +4 -0
- package/dist/cacache.js +1 -1
- package/dist/cacache.js.map +3 -3
- package/dist/constants/packages.js +1 -1
- package/dist/constants/packages.js.map +3 -3
- package/dist/debug.d.ts +0 -7
- package/dist/debug.js +2 -2
- package/dist/debug.js.map +3 -3
- package/dist/dlx-binary.js +1 -1
- package/dist/dlx-binary.js.map +3 -3
- package/dist/effects/text-shimmer.js +1 -1
- package/dist/effects/text-shimmer.js.map +2 -2
- package/dist/env/ci.d.ts +1 -1
- package/dist/env/ci.js +1 -1
- package/dist/env/ci.js.map +3 -3
- package/dist/env/debug.d.ts +1 -1
- package/dist/env/debug.js +1 -1
- package/dist/env/debug.js.map +3 -3
- package/dist/env/github.d.ts +40 -0
- package/dist/env/github.js +3 -0
- package/dist/env/github.js.map +7 -0
- package/dist/env/home.d.ts +1 -1
- package/dist/env/home.js +1 -1
- package/dist/env/home.js.map +3 -3
- package/dist/env/locale.d.ts +15 -0
- package/dist/env/locale.js +3 -0
- package/dist/env/locale.js.map +7 -0
- package/dist/env/node-auth-token.d.ts +1 -1
- package/dist/env/node-auth-token.js +1 -1
- package/dist/env/node-auth-token.js.map +3 -3
- package/dist/env/node-env.d.ts +1 -1
- package/dist/env/node-env.js +1 -1
- package/dist/env/node-env.js.map +3 -3
- package/dist/env/npm.d.ts +25 -0
- package/dist/env/npm.js +3 -0
- package/dist/env/npm.js.map +7 -0
- package/dist/env/path.d.ts +1 -1
- package/dist/env/path.js +1 -1
- package/dist/env/path.js.map +3 -3
- package/dist/env/pre-commit.d.ts +1 -1
- package/dist/env/pre-commit.js +1 -1
- package/dist/env/pre-commit.js.map +3 -3
- package/dist/env/rewire.d.ts +106 -0
- package/dist/env/rewire.js +3 -0
- package/dist/env/rewire.js.map +7 -0
- package/dist/env/shell.d.ts +1 -1
- package/dist/env/shell.js +1 -1
- package/dist/env/shell.js.map +3 -3
- package/dist/env/socket-cli-shadow.d.ts +30 -0
- package/dist/env/socket-cli-shadow.js +3 -0
- package/dist/env/socket-cli-shadow.js.map +7 -0
- package/dist/env/socket-cli.d.ts +72 -0
- package/dist/env/socket-cli.js +3 -0
- package/dist/env/socket-cli.js.map +7 -0
- package/dist/env/socket.d.ts +75 -0
- package/dist/env/socket.js +3 -0
- package/dist/env/socket.js.map +7 -0
- package/dist/env/temp-dir.d.ts +15 -0
- package/dist/env/temp-dir.js +3 -0
- package/dist/env/temp-dir.js.map +7 -0
- package/dist/env/term.d.ts +1 -1
- package/dist/env/term.js +1 -1
- package/dist/env/term.js.map +3 -3
- package/dist/env/test.d.ts +15 -0
- package/dist/env/test.js +3 -0
- package/dist/env/test.js.map +7 -0
- package/dist/env/windows.d.ts +20 -0
- package/dist/env/windows.js +3 -0
- package/dist/env/windows.js.map +7 -0
- package/dist/env/xdg.d.ts +15 -0
- package/dist/env/xdg.js +3 -0
- package/dist/env/xdg.js.map +7 -0
- package/dist/env.d.ts +67 -0
- package/dist/env.js +1 -1
- package/dist/env.js.map +3 -3
- package/dist/fs.d.ts +7 -0
- package/dist/fs.js +3 -3
- package/dist/fs.js.map +3 -3
- package/dist/github.js +1 -1
- package/dist/github.js.map +3 -3
- package/dist/globs.js +1 -1
- package/dist/globs.js.map +2 -2
- package/dist/ipc.d.ts +1 -1
- package/dist/ipc.js +1 -1
- package/dist/ipc.js.map +3 -3
- package/dist/logger.d.ts +2 -1
- package/dist/logger.js +1 -1
- package/dist/logger.js.map +3 -3
- package/dist/packages/isolation.js +1 -1
- package/dist/packages/isolation.js.map +3 -3
- package/dist/packages/normalize.js +1 -1
- package/dist/packages/normalize.js.map +3 -3
- package/dist/packages/operations.js +1 -1
- package/dist/packages/operations.js.map +3 -3
- package/dist/path.d.ts +2 -2
- package/dist/path.js +1 -1
- package/dist/path.js.map +3 -3
- package/dist/paths/rewire.d.ts +71 -0
- package/dist/paths/rewire.js +3 -0
- package/dist/paths/rewire.js.map +7 -0
- package/dist/paths.d.ts +26 -0
- package/dist/paths.js +1 -1
- package/dist/paths.js.map +3 -3
- package/dist/spawn.js +1 -1
- package/dist/spawn.js.map +3 -3
- package/dist/spinner.js +1 -1
- package/dist/spinner.js.map +2 -2
- package/package.json +39 -226
- package/dist/env/appdata.d.ts +0 -1
- package/dist/env/appdata.js +0 -3
- package/dist/env/appdata.js.map +0 -7
- package/dist/env/comspec.d.ts +0 -1
- package/dist/env/comspec.js +0 -3
- package/dist/env/comspec.js.map +0 -7
- package/dist/env/getters.d.ts +0 -40
- package/dist/env/getters.js +0 -3
- package/dist/env/getters.js.map +0 -7
- package/dist/env/github-api-url.d.ts +0 -1
- package/dist/env/github-api-url.js +0 -3
- package/dist/env/github-api-url.js.map +0 -7
- package/dist/env/github-base-ref.d.ts +0 -1
- package/dist/env/github-base-ref.js +0 -3
- package/dist/env/github-base-ref.js.map +0 -7
- package/dist/env/github-ref-name.d.ts +0 -1
- package/dist/env/github-ref-name.js +0 -3
- package/dist/env/github-ref-name.js.map +0 -7
- package/dist/env/github-ref-type.d.ts +0 -1
- package/dist/env/github-ref-type.js +0 -3
- package/dist/env/github-ref-type.js.map +0 -7
- package/dist/env/github-repository.d.ts +0 -1
- package/dist/env/github-repository.js +0 -3
- package/dist/env/github-repository.js.map +0 -7
- package/dist/env/github-server-url.d.ts +0 -1
- package/dist/env/github-server-url.js +0 -3
- package/dist/env/github-server-url.js.map +0 -7
- package/dist/env/github-token.d.ts +0 -1
- package/dist/env/github-token.js +0 -3
- package/dist/env/github-token.js.map +0 -7
- package/dist/env/jest-worker-id.d.ts +0 -1
- package/dist/env/jest-worker-id.js +0 -3
- package/dist/env/jest-worker-id.js.map +0 -7
- package/dist/env/lang.d.ts +0 -1
- package/dist/env/lang.js +0 -3
- package/dist/env/lang.js.map +0 -7
- package/dist/env/lc-all.d.ts +0 -1
- package/dist/env/lc-all.js +0 -3
- package/dist/env/lc-all.js.map +0 -7
- package/dist/env/lc-messages.d.ts +0 -1
- package/dist/env/lc-messages.js +0 -3
- package/dist/env/lc-messages.js.map +0 -7
- package/dist/env/localappdata.d.ts +0 -1
- package/dist/env/localappdata.js +0 -3
- package/dist/env/localappdata.js.map +0 -7
- package/dist/env/npm-config-registry.d.ts +0 -1
- package/dist/env/npm-config-registry.js +0 -3
- package/dist/env/npm-config-registry.js.map +0 -7
- package/dist/env/npm-config-user-agent.d.ts +0 -1
- package/dist/env/npm-config-user-agent.js +0 -3
- package/dist/env/npm-config-user-agent.js.map +0 -7
- package/dist/env/npm-lifecycle-event.d.ts +0 -1
- package/dist/env/npm-lifecycle-event.js +0 -3
- package/dist/env/npm-lifecycle-event.js.map +0 -7
- package/dist/env/npm-registry.d.ts +0 -1
- package/dist/env/npm-registry.js +0 -3
- package/dist/env/npm-registry.js.map +0 -7
- package/dist/env/npm-token.d.ts +0 -1
- package/dist/env/npm-token.js +0 -3
- package/dist/env/npm-token.js.map +0 -7
- package/dist/env/socket-accept-risks.d.ts +0 -1
- package/dist/env/socket-accept-risks.js +0 -3
- package/dist/env/socket-accept-risks.js.map +0 -7
- package/dist/env/socket-api-base-url.d.ts +0 -1
- package/dist/env/socket-api-base-url.js +0 -3
- package/dist/env/socket-api-base-url.js.map +0 -7
- package/dist/env/socket-api-proxy.d.ts +0 -1
- package/dist/env/socket-api-proxy.js +0 -3
- package/dist/env/socket-api-proxy.js.map +0 -7
- package/dist/env/socket-api-timeout.d.ts +0 -1
- package/dist/env/socket-api-timeout.js +0 -3
- package/dist/env/socket-api-timeout.js.map +0 -7
- package/dist/env/socket-api-token.d.ts +0 -1
- package/dist/env/socket-api-token.js +0 -3
- package/dist/env/socket-api-token.js.map +0 -7
- package/dist/env/socket-cacache-dir.d.ts +0 -1
- package/dist/env/socket-cacache-dir.js +0 -3
- package/dist/env/socket-cacache-dir.js.map +0 -7
- package/dist/env/socket-cli-accept-risks.d.ts +0 -1
- package/dist/env/socket-cli-accept-risks.js +0 -3
- package/dist/env/socket-cli-accept-risks.js.map +0 -7
- package/dist/env/socket-cli-api-base-url.d.ts +0 -1
- package/dist/env/socket-cli-api-base-url.js +0 -3
- package/dist/env/socket-cli-api-base-url.js.map +0 -7
- package/dist/env/socket-cli-api-proxy.d.ts +0 -1
- package/dist/env/socket-cli-api-proxy.js +0 -3
- package/dist/env/socket-cli-api-proxy.js.map +0 -7
- package/dist/env/socket-cli-api-timeout.d.ts +0 -1
- package/dist/env/socket-cli-api-timeout.js +0 -3
- package/dist/env/socket-cli-api-timeout.js.map +0 -7
- package/dist/env/socket-cli-api-token.d.ts +0 -1
- package/dist/env/socket-cli-api-token.js +0 -3
- package/dist/env/socket-cli-api-token.js.map +0 -7
- package/dist/env/socket-cli-config.d.ts +0 -1
- package/dist/env/socket-cli-config.js +0 -3
- package/dist/env/socket-cli-config.js.map +0 -7
- package/dist/env/socket-cli-fix.d.ts +0 -1
- package/dist/env/socket-cli-fix.js +0 -3
- package/dist/env/socket-cli-fix.js.map +0 -7
- package/dist/env/socket-cli-no-api-token.d.ts +0 -1
- package/dist/env/socket-cli-no-api-token.js +0 -3
- package/dist/env/socket-cli-no-api-token.js.map +0 -7
- package/dist/env/socket-cli-optimize.d.ts +0 -1
- package/dist/env/socket-cli-optimize.js +0 -3
- package/dist/env/socket-cli-optimize.js.map +0 -7
- package/dist/env/socket-cli-org-slug.d.ts +0 -1
- package/dist/env/socket-cli-org-slug.js +0 -3
- package/dist/env/socket-cli-org-slug.js.map +0 -7
- package/dist/env/socket-cli-shadow-accept-risks.d.ts +0 -1
- package/dist/env/socket-cli-shadow-accept-risks.js +0 -3
- package/dist/env/socket-cli-shadow-accept-risks.js.map +0 -7
- package/dist/env/socket-cli-shadow-api-token.d.ts +0 -1
- package/dist/env/socket-cli-shadow-api-token.js +0 -3
- package/dist/env/socket-cli-shadow-api-token.js.map +0 -7
- package/dist/env/socket-cli-shadow-bin.d.ts +0 -1
- package/dist/env/socket-cli-shadow-bin.js +0 -3
- package/dist/env/socket-cli-shadow-bin.js.map +0 -7
- package/dist/env/socket-cli-shadow-progress.d.ts +0 -1
- package/dist/env/socket-cli-shadow-progress.js +0 -3
- package/dist/env/socket-cli-shadow-progress.js.map +0 -7
- package/dist/env/socket-cli-shadow-silent.d.ts +0 -1
- package/dist/env/socket-cli-shadow-silent.js +0 -3
- package/dist/env/socket-cli-shadow-silent.js.map +0 -7
- package/dist/env/socket-cli-view-all-risks.d.ts +0 -1
- package/dist/env/socket-cli-view-all-risks.js +0 -3
- package/dist/env/socket-cli-view-all-risks.js.map +0 -7
- package/dist/env/socket-config.d.ts +0 -1
- package/dist/env/socket-config.js +0 -3
- package/dist/env/socket-config.js.map +0 -7
- package/dist/env/socket-debug.d.ts +0 -1
- package/dist/env/socket-debug.js +0 -3
- package/dist/env/socket-debug.js.map +0 -7
- package/dist/env/socket-home.d.ts +0 -1
- package/dist/env/socket-home.js +0 -3
- package/dist/env/socket-home.js.map +0 -7
- package/dist/env/socket-no-api-token.d.ts +0 -1
- package/dist/env/socket-no-api-token.js +0 -3
- package/dist/env/socket-no-api-token.js.map +0 -7
- package/dist/env/socket-npm-registry.d.ts +0 -1
- package/dist/env/socket-npm-registry.js +0 -3
- package/dist/env/socket-npm-registry.js.map +0 -7
- package/dist/env/socket-org-slug.d.ts +0 -1
- package/dist/env/socket-org-slug.js +0 -3
- package/dist/env/socket-org-slug.js.map +0 -7
- package/dist/env/socket-registry-url.d.ts +0 -1
- package/dist/env/socket-registry-url.js +0 -3
- package/dist/env/socket-registry-url.js.map +0 -7
- package/dist/env/socket-view-all-risks.d.ts +0 -1
- package/dist/env/socket-view-all-risks.js +0 -3
- package/dist/env/socket-view-all-risks.js.map +0 -7
- package/dist/env/temp.d.ts +0 -1
- package/dist/env/temp.js +0 -3
- package/dist/env/temp.js.map +0 -7
- package/dist/env/tmp.d.ts +0 -1
- package/dist/env/tmp.js +0 -3
- package/dist/env/tmp.js.map +0 -7
- package/dist/env/tmpdir.d.ts +0 -1
- package/dist/env/tmpdir.js +0 -3
- package/dist/env/tmpdir.js.map +0 -7
- package/dist/env/userprofile.d.ts +0 -1
- package/dist/env/userprofile.js +0 -3
- package/dist/env/userprofile.js.map +0 -7
- package/dist/env/vitest.d.ts +0 -1
- package/dist/env/vitest.js +0 -3
- package/dist/env/vitest.js.map +0 -7
- package/dist/env/xdg-cache-home.d.ts +0 -1
- package/dist/env/xdg-cache-home.js +0 -3
- package/dist/env/xdg-cache-home.js.map +0 -7
- package/dist/env/xdg-config-home.d.ts +0 -1
- package/dist/env/xdg-config-home.js +0 -3
- package/dist/env/xdg-config-home.js.map +0 -7
- package/dist/env/xdg-data-home.d.ts +0 -1
- package/dist/env/xdg-data-home.js +0 -3
- package/dist/env/xdg-data-home.js.map +0 -7
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/env/socket.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Socket Security environment variable getters.\n */\n\nimport { envAsBoolean, envAsNumber } from '#env/helpers'\nimport { getEnvValue } from '#env/rewire'\n\n/**\n * SOCKET_ACCEPT_RISKS environment variable getter.\n * Whether to accept all Socket Security risks.\n */\nexport function getSocketAcceptRisks(): boolean {\n return envAsBoolean(getEnvValue('SOCKET_ACCEPT_RISKS'))\n}\n\n/**\n * SOCKET_API_BASE_URL environment variable getter.\n * Socket Security API base URL.\n */\nexport function getSocketApiBaseUrl(): string | undefined {\n return getEnvValue('SOCKET_API_BASE_URL')\n}\n\n/**\n * SOCKET_API_PROXY environment variable getter.\n * Proxy URL for Socket Security API requests.\n */\nexport function getSocketApiProxy(): string | undefined {\n return getEnvValue('SOCKET_API_PROXY')\n}\n\n/**\n * SOCKET_API_TIMEOUT environment variable getter.\n * Timeout in milliseconds for Socket Security API requests.\n */\nexport function getSocketApiTimeout(): number {\n return envAsNumber(getEnvValue('SOCKET_API_TIMEOUT'))\n}\n\n/**\n * SOCKET_API_TOKEN environment variable getter.\n * Socket Security API authentication token.\n */\nexport function getSocketApiToken(): string | undefined {\n return getEnvValue('SOCKET_API_TOKEN')\n}\n\n/**\n * SOCKET_CACACHE_DIR environment variable getter.\n * Overrides the default Socket cacache directory location.\n */\nexport function getSocketCacacheDir(): string | undefined {\n return getEnvValue('SOCKET_CACACHE_DIR')\n}\n\n/**\n * SOCKET_CONFIG environment variable getter.\n * Socket Security configuration file path.\n */\nexport function getSocketConfig(): string | undefined {\n return getEnvValue('SOCKET_CONFIG')\n}\n\n/**\n * SOCKET_DEBUG environment variable getter.\n * Controls Socket-specific debug output.\n */\nexport function getSocketDebug(): string | undefined {\n return getEnvValue('SOCKET_DEBUG')\n}\n\n/**\n * SOCKET_DLX_DIR environment variable getter.\n * Overrides the default Socket DLX directory location.\n */\nexport function getSocketDlxDirEnv(): string | undefined {\n return getEnvValue('SOCKET_DLX_DIR')\n}\n\n/**\n * SOCKET_HOME environment variable getter.\n * Socket Security home directory path.\n */\nexport function getSocketHome(): string | undefined {\n return getEnvValue('SOCKET_HOME')\n}\n\n/**\n * SOCKET_NO_API_TOKEN environment variable getter.\n * Whether to skip Socket Security API token requirement.\n */\nexport function getSocketNoApiToken(): boolean {\n return envAsBoolean(getEnvValue('SOCKET_NO_API_TOKEN'))\n}\n\n/**\n * SOCKET_NPM_REGISTRY environment variable getter.\n * Socket NPM registry URL (alternative name).\n */\nexport function getSocketNpmRegistry(): string | undefined {\n return getEnvValue('SOCKET_NPM_REGISTRY')\n}\n\n/**\n * SOCKET_ORG_SLUG environment variable getter.\n * Socket Security organization slug identifier.\n */\nexport function getSocketOrgSlug(): string | undefined {\n return getEnvValue('SOCKET_ORG_SLUG')\n}\n\n/**\n * SOCKET_REGISTRY_URL environment variable getter.\n * Socket Registry URL for package installation.\n */\nexport function getSocketRegistryUrl(): string | undefined {\n return getEnvValue('SOCKET_REGISTRY_URL')\n}\n\n/**\n * SOCKET_VIEW_ALL_RISKS environment variable getter.\n * Whether to view all Socket Security risks.\n */\nexport function getSocketViewAllRisks(): boolean {\n return envAsBoolean(getEnvValue('SOCKET_VIEW_ALL_RISKS'))\n}\n"],
|
|
5
|
+
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,EAAA,wBAAAC,EAAA,sBAAAC,EAAA,wBAAAC,EAAA,sBAAAC,EAAA,wBAAAC,EAAA,oBAAAC,EAAA,mBAAAC,EAAA,uBAAAC,EAAA,kBAAAC,EAAA,wBAAAC,EAAA,yBAAAC,EAAA,qBAAAC,EAAA,yBAAAC,EAAA,0BAAAC,IAAA,eAAAC,EAAAjB,GAIA,IAAAkB,EAA0C,wBAC1CC,EAA4B,uBAMrB,SAASjB,GAAgC,CAC9C,SAAO,mBAAa,eAAY,qBAAqB,CAAC,CACxD,CAMO,SAASC,GAA0C,CACxD,SAAO,eAAY,qBAAqB,CAC1C,CAMO,SAASC,GAAwC,CACtD,SAAO,eAAY,kBAAkB,CACvC,CAMO,SAASC,GAA8B,CAC5C,SAAO,kBAAY,eAAY,oBAAoB,CAAC,CACtD,CAMO,SAASC,GAAwC,CACtD,SAAO,eAAY,kBAAkB,CACvC,CAMO,SAASC,GAA0C,CACxD,SAAO,eAAY,oBAAoB,CACzC,CAMO,SAASC,GAAsC,CACpD,SAAO,eAAY,eAAe,CACpC,CAMO,SAASC,GAAqC,CACnD,SAAO,eAAY,cAAc,CACnC,CAMO,SAASC,GAAyC,CACvD,SAAO,eAAY,gBAAgB,CACrC,CAMO,SAASC,GAAoC,CAClD,SAAO,eAAY,aAAa,CAClC,CAMO,SAASC,GAA+B,CAC7C,SAAO,mBAAa,eAAY,qBAAqB,CAAC,CACxD,CAMO,SAASC,GAA2C,CACzD,SAAO,eAAY,qBAAqB,CAC1C,CAMO,SAASC,GAAuC,CACrD,SAAO,eAAY,iBAAiB,CACtC,CAMO,SAASC,GAA2C,CACzD,SAAO,eAAY,qBAAqB,CAC1C,CAMO,SAASC,GAAiC,CAC/C,SAAO,mBAAa,eAAY,uBAAuB,CAAC,CAC1D",
|
|
6
|
+
"names": ["socket_exports", "__export", "getSocketAcceptRisks", "getSocketApiBaseUrl", "getSocketApiProxy", "getSocketApiTimeout", "getSocketApiToken", "getSocketCacacheDir", "getSocketConfig", "getSocketDebug", "getSocketDlxDirEnv", "getSocketHome", "getSocketNoApiToken", "getSocketNpmRegistry", "getSocketOrgSlug", "getSocketRegistryUrl", "getSocketViewAllRisks", "__toCommonJS", "import_helpers", "import_rewire"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TMPDIR environment variable.
|
|
3
|
+
* Unix/macOS temporary directory path.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getTmpdir(): string | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* TEMP environment variable.
|
|
8
|
+
* Windows temporary directory path.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getTemp(): string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* TMP environment variable.
|
|
13
|
+
* Alternative temporary directory path.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getTmp(): string | undefined;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* Socket Lib - Built with esbuild */
|
|
2
|
+
var u=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var p=(e,n)=>{for(var r in n)u(e,r,{get:n[r],enumerable:!0})},T=(e,n,r,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of f(n))!g.call(e,t)&&t!==r&&u(e,t,{get:()=>n[t],enumerable:!(o=d(n,t))||o.enumerable});return e};var m=e=>T(u({},"__esModule",{value:!0}),e);var M={};p(M,{getTemp:()=>s,getTmp:()=>x,getTmpdir:()=>c});module.exports=m(M);var i=require("#env/rewire");function c(){return(0,i.getEnvValue)("TMPDIR")}function s(){return(0,i.getEnvValue)("TEMP")}function x(){return(0,i.getEnvValue)("TMP")}0&&(module.exports={getTemp,getTmp,getTmpdir});
|
|
3
|
+
//# sourceMappingURL=temp-dir.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/env/temp-dir.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Temporary directory environment variable getters.\n * Different platforms use different environment variables for temp directories.\n */\n\nimport { getEnvValue } from '#env/rewire'\n\n/**\n * TMPDIR environment variable.\n * Unix/macOS temporary directory path.\n */\nexport function getTmpdir(): string | undefined {\n return getEnvValue('TMPDIR')\n}\n\n/**\n * TEMP environment variable.\n * Windows temporary directory path.\n */\nexport function getTemp(): string | undefined {\n return getEnvValue('TEMP')\n}\n\n/**\n * TMP environment variable.\n * Alternative temporary directory path.\n */\nexport function getTmp(): string | undefined {\n return getEnvValue('TMP')\n}\n"],
|
|
5
|
+
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,WAAAC,EAAA,cAAAC,IAAA,eAAAC,EAAAL,GAKA,IAAAM,EAA4B,uBAMrB,SAASF,GAAgC,CAC9C,SAAO,eAAY,QAAQ,CAC7B,CAMO,SAASF,GAA8B,CAC5C,SAAO,eAAY,MAAM,CAC3B,CAMO,SAASC,GAA6B,CAC3C,SAAO,eAAY,KAAK,CAC1B",
|
|
6
|
+
"names": ["temp_dir_exports", "__export", "getTemp", "getTmp", "getTmpdir", "__toCommonJS", "import_rewire"]
|
|
7
|
+
}
|
package/dist/env/term.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare function getTerm(): string | undefined;
|
package/dist/env/term.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* Socket Lib - Built with esbuild */
|
|
2
|
-
var
|
|
2
|
+
var i=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var d=(n,e)=>{for(var t in e)i(n,t,{get:e[t],enumerable:!0})},p=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of g(e))!m.call(n,r)&&r!==t&&i(n,r,{get:()=>e[r],enumerable:!(o=f(e,r))||o.enumerable});return n};var E=n=>p(i({},"__esModule",{value:!0}),n);var a={};d(a,{getTerm:()=>T});module.exports=E(a);var u=require("#env/rewire");function T(){return(0,u.getEnvValue)("TERM")}0&&(module.exports={getTerm});
|
|
3
3
|
//# sourceMappingURL=term.js.map
|
package/dist/env/term.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/env/term.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * TERM environment variable
|
|
5
|
-
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,
|
|
6
|
-
"names": ["term_exports", "__export", "
|
|
4
|
+
"sourcesContent": ["/**\n * TERM environment variable getter.\n * Terminal type identifier.\n */\n\nimport { getEnvValue } from '#env/rewire'\n\nexport function getTerm(): string | undefined {\n return getEnvValue('TERM')\n}\n"],
|
|
5
|
+
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAKA,IAAAI,EAA4B,uBAErB,SAASF,GAA8B,CAC5C,SAAO,eAAY,MAAM,CAC3B",
|
|
6
|
+
"names": ["term_exports", "__export", "getTerm", "__toCommonJS", "import_rewire"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JEST_WORKER_ID environment variable.
|
|
3
|
+
* Set when running tests with Jest.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getJestWorkerId(): string;
|
|
6
|
+
/**
|
|
7
|
+
* VITEST environment variable.
|
|
8
|
+
* Set when running tests with Vitest.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getVitest(): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Check if code is running in a test environment.
|
|
13
|
+
* Checks NODE_ENV, VITEST, and JEST_WORKER_ID.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isTest(): boolean;
|
package/dist/env/test.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* Socket Lib - Built with esbuild */
|
|
2
|
+
var i=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var a=(e,t)=>{for(var r in t)i(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,u)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of p(t))!v.call(e,n)&&n!==r&&i(e,n,{get:()=>t[n],enumerable:!(u=m(t,n))||u.enumerable});return e};var d=e=>c(i({},"__esModule",{value:!0}),e);var T={};a(T,{getJestWorkerId:()=>f,getVitest:()=>g,isTest:()=>l});module.exports=d(T);var o=require("#env/helpers"),E=require("#env/node-env"),s=require("#env/rewire");function f(){return(0,o.envAsString)((0,s.getEnvValue)("JEST_WORKER_ID"))}function g(){return(0,o.envAsBoolean)((0,s.getEnvValue)("VITEST"))}function l(){return(0,o.envAsString)((0,E.getNodeEnv)())==="test"||g()||!!f()}0&&(module.exports={getJestWorkerId,getVitest,isTest});
|
|
3
|
+
//# sourceMappingURL=test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/env/test.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Test environment variable getters and detection.\n * Provides access to test framework environment variables and utilities.\n */\n\nimport { envAsBoolean, envAsString } from '#env/helpers'\nimport { getNodeEnv } from '#env/node-env'\nimport { getEnvValue } from '#env/rewire'\n\n/**\n * JEST_WORKER_ID environment variable.\n * Set when running tests with Jest.\n */\nexport function getJestWorkerId(): string {\n return envAsString(getEnvValue('JEST_WORKER_ID'))\n}\n\n/**\n * VITEST environment variable.\n * Set when running tests with Vitest.\n */\nexport function getVitest(): boolean {\n return envAsBoolean(getEnvValue('VITEST'))\n}\n\n/**\n * Check if code is running in a test environment.\n * Checks NODE_ENV, VITEST, and JEST_WORKER_ID.\n */\nexport function isTest(): boolean {\n const nodeEnv = envAsString(getNodeEnv())\n return nodeEnv === 'test' || getVitest() || !!getJestWorkerId()\n}\n"],
|
|
5
|
+
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,cAAAC,EAAA,WAAAC,IAAA,eAAAC,EAAAL,GAKA,IAAAM,EAA0C,wBAC1CC,EAA2B,yBAC3BC,EAA4B,uBAMrB,SAASN,GAA0B,CACxC,SAAO,kBAAY,eAAY,gBAAgB,CAAC,CAClD,CAMO,SAASC,GAAqB,CACnC,SAAO,mBAAa,eAAY,QAAQ,CAAC,CAC3C,CAMO,SAASC,GAAkB,CAEhC,SADgB,kBAAY,cAAW,CAAC,IACrB,QAAUD,EAAU,GAAK,CAAC,CAACD,EAAgB,CAChE",
|
|
6
|
+
"names": ["test_exports", "__export", "getJestWorkerId", "getVitest", "isTest", "__toCommonJS", "import_helpers", "import_node_env", "import_rewire"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* APPDATA environment variable.
|
|
3
|
+
* Points to the Application Data directory on Windows.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getAppdata(): string | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* LOCALAPPDATA environment variable.
|
|
8
|
+
* Points to the Local Application Data directory on Windows.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getLocalappdata(): string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* USERPROFILE environment variable.
|
|
13
|
+
* Windows user home directory path.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getUserprofile(): string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* COMSPEC environment variable.
|
|
18
|
+
* Points to the Windows command processor (typically cmd.exe).
|
|
19
|
+
*/
|
|
20
|
+
export declare function getComspec(): string | undefined;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* Socket Lib - Built with esbuild */
|
|
2
|
+
var o=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var g=(n,e)=>{for(var i in e)o(n,i,{get:e[i],enumerable:!0})},A=(n,e,i,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of d(e))!f.call(n,t)&&t!==i&&o(n,t,{get:()=>e[t],enumerable:!(u=p(e,t))||u.enumerable});return n};var a=n=>A(o({},"__esModule",{value:!0}),n);var C={};g(C,{getAppdata:()=>c,getComspec:()=>x,getLocalappdata:()=>s,getUserprofile:()=>P});module.exports=a(C);var r=require("#env/rewire");function c(){return(0,r.getEnvValue)("APPDATA")}function s(){return(0,r.getEnvValue)("LOCALAPPDATA")}function P(){return(0,r.getEnvValue)("USERPROFILE")}function x(){return(0,r.getEnvValue)("COMSPEC")}0&&(module.exports={getAppdata,getComspec,getLocalappdata,getUserprofile});
|
|
3
|
+
//# sourceMappingURL=windows.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/env/windows.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Windows environment variable getters.\n * Provides access to Windows-specific user directory paths.\n */\n\nimport { getEnvValue } from '#env/rewire'\n\n/**\n * APPDATA environment variable.\n * Points to the Application Data directory on Windows.\n */\nexport function getAppdata(): string | undefined {\n return getEnvValue('APPDATA')\n}\n\n/**\n * LOCALAPPDATA environment variable.\n * Points to the Local Application Data directory on Windows.\n */\nexport function getLocalappdata(): string | undefined {\n return getEnvValue('LOCALAPPDATA')\n}\n\n/**\n * USERPROFILE environment variable.\n * Windows user home directory path.\n */\nexport function getUserprofile(): string | undefined {\n return getEnvValue('USERPROFILE')\n}\n\n/**\n * COMSPEC environment variable.\n * Points to the Windows command processor (typically cmd.exe).\n */\nexport function getComspec(): string | undefined {\n return getEnvValue('COMSPEC')\n}\n"],
|
|
5
|
+
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,EAAA,eAAAC,EAAA,oBAAAC,EAAA,mBAAAC,IAAA,eAAAC,EAAAN,GAKA,IAAAO,EAA4B,uBAMrB,SAASL,GAAiC,CAC/C,SAAO,eAAY,SAAS,CAC9B,CAMO,SAASE,GAAsC,CACpD,SAAO,eAAY,cAAc,CACnC,CAMO,SAASC,GAAqC,CACnD,SAAO,eAAY,aAAa,CAClC,CAMO,SAASF,GAAiC,CAC/C,SAAO,eAAY,SAAS,CAC9B",
|
|
6
|
+
"names": ["windows_exports", "__export", "getAppdata", "getComspec", "getLocalappdata", "getUserprofile", "__toCommonJS", "import_rewire"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XDG_CACHE_HOME environment variable.
|
|
3
|
+
* XDG Base Directory specification cache directory.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getXdgCacheHome(): string | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* XDG_CONFIG_HOME environment variable.
|
|
8
|
+
* XDG Base Directory specification config directory.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getXdgConfigHome(): string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* XDG_DATA_HOME environment variable.
|
|
13
|
+
* Points to the user's data directory on Unix systems.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getXdgDataHome(): string | undefined;
|
package/dist/env/xdg.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* Socket Lib - Built with esbuild */
|
|
2
|
+
var g=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var H=(n,e)=>{for(var r in e)g(n,r,{get:e[r],enumerable:!0})},X=(n,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of d(e))!f.call(n,t)&&t!==r&&g(n,t,{get:()=>e[t],enumerable:!(i=u(e,t))||i.enumerable});return n};var _=n=>X(g({},"__esModule",{value:!0}),n);var E={};H(E,{getXdgCacheHome:()=>m,getXdgConfigHome:()=>C,getXdgDataHome:()=>D});module.exports=_(E);var o=require("#env/rewire");function m(){return(0,o.getEnvValue)("XDG_CACHE_HOME")}function C(){return(0,o.getEnvValue)("XDG_CONFIG_HOME")}function D(){return(0,o.getEnvValue)("XDG_DATA_HOME")}0&&(module.exports={getXdgCacheHome,getXdgConfigHome,getXdgDataHome});
|
|
3
|
+
//# sourceMappingURL=xdg.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/env/xdg.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview XDG Base Directory Specification environment variable getters.\n * Provides access to XDG user directories on Unix systems.\n */\n\nimport { getEnvValue } from '#env/rewire'\n\n/**\n * XDG_CACHE_HOME environment variable.\n * XDG Base Directory specification cache directory.\n */\nexport function getXdgCacheHome(): string | undefined {\n return getEnvValue('XDG_CACHE_HOME')\n}\n\n/**\n * XDG_CONFIG_HOME environment variable.\n * XDG Base Directory specification config directory.\n */\nexport function getXdgConfigHome(): string | undefined {\n return getEnvValue('XDG_CONFIG_HOME')\n}\n\n/**\n * XDG_DATA_HOME environment variable.\n * Points to the user's data directory on Unix systems.\n */\nexport function getXdgDataHome(): string | undefined {\n return getEnvValue('XDG_DATA_HOME')\n}\n"],
|
|
5
|
+
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,qBAAAC,EAAA,mBAAAC,IAAA,eAAAC,EAAAL,GAKA,IAAAM,EAA4B,uBAMrB,SAASJ,GAAsC,CACpD,SAAO,eAAY,gBAAgB,CACrC,CAMO,SAASC,GAAuC,CACrD,SAAO,eAAY,iBAAiB,CACtC,CAMO,SAASC,GAAqC,CACnD,SAAO,eAAY,eAAe,CACpC",
|
|
6
|
+
"names": ["xdg_exports", "__export", "getXdgCacheHome", "getXdgConfigHome", "getXdgDataHome", "__toCommonJS", "import_rewire"]
|
|
7
|
+
}
|
package/dist/env.d.ts
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a case-insensitive environment variable Proxy for Windows compatibility.
|
|
3
|
+
* On Windows, environment variables are case-insensitive (PATH vs Path vs path).
|
|
4
|
+
* This Proxy provides consistent access regardless of case, with priority given
|
|
5
|
+
* to exact matches, then case-insensitive matches for known vars.
|
|
6
|
+
*
|
|
7
|
+
* **Use Cases:**
|
|
8
|
+
* - Cross-platform test environments needing consistent env var access
|
|
9
|
+
* - Windows compatibility when passing env to child processes
|
|
10
|
+
* - Merging environment overrides while preserving case-insensitive lookups
|
|
11
|
+
*
|
|
12
|
+
* **Performance Note:**
|
|
13
|
+
* Proxy operations have runtime overhead. Only use when Windows case-insensitive
|
|
14
|
+
* access is required. For most use cases, process.env directly is sufficient.
|
|
15
|
+
*
|
|
16
|
+
* @param base - Base environment object (usually process.env)
|
|
17
|
+
* @param overrides - Optional overrides to merge
|
|
18
|
+
* @returns Proxy that handles case-insensitive env var access
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Create a Proxy with overrides
|
|
22
|
+
* const env = createEnvProxy(process.env, { NODE_ENV: 'test' })
|
|
23
|
+
* console.log(env.PATH) // Works with any case: PATH, Path, path
|
|
24
|
+
* console.log(env.NODE_ENV) // 'test'
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Pass to child process spawn
|
|
28
|
+
* import { createEnvProxy } from '@socketsecurity/lib/env'
|
|
29
|
+
* import { spawn } from '@socketsecurity/lib/spawn'
|
|
30
|
+
*
|
|
31
|
+
* spawn('node', ['script.js'], {
|
|
32
|
+
* env: createEnvProxy(process.env, { NODE_ENV: 'test' })
|
|
33
|
+
* })
|
|
34
|
+
*/
|
|
35
|
+
export declare function createEnvProxy(base: NodeJS.ProcessEnv, overrides?: Record<string, string | undefined>): NodeJS.ProcessEnv;
|
|
1
36
|
/**
|
|
2
37
|
* Convert an environment variable value to a boolean.
|
|
3
38
|
*/
|
|
@@ -13,3 +48,35 @@ export declare function envAsNumber(value: unknown, defaultValue?: number): numb
|
|
|
13
48
|
*/
|
|
14
49
|
/*@__NO_SIDE_EFFECTS__*/
|
|
15
50
|
export declare function envAsString(value: unknown, defaultValue?: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* Find a case-insensitive environment variable key match.
|
|
53
|
+
* Searches for an environment variable key that matches the given uppercase name,
|
|
54
|
+
* using optimized fast-path checks to minimize expensive toUpperCase() calls.
|
|
55
|
+
*
|
|
56
|
+
* **Use Cases:**
|
|
57
|
+
* - Finding PATH when env object has "Path" or "path"
|
|
58
|
+
* - Cross-platform env var access where case may vary
|
|
59
|
+
* - Custom case-insensitive env lookups
|
|
60
|
+
*
|
|
61
|
+
* **Performance:**
|
|
62
|
+
* - Fast path: Checks length first (O(1)) before toUpperCase (expensive)
|
|
63
|
+
* - Only converts to uppercase when length matches
|
|
64
|
+
* - Early exit on first match
|
|
65
|
+
*
|
|
66
|
+
* @param env - Environment object or env-like record to search
|
|
67
|
+
* @param upperEnvVarName - Uppercase environment variable name to find (e.g., 'PATH')
|
|
68
|
+
* @returns The actual key from env that matches (e.g., 'Path'), or undefined
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* // Find PATH regardless of case
|
|
72
|
+
* const envObj = { Path: 'C:\\Windows', NODE_ENV: 'test' }
|
|
73
|
+
* const key = findCaseInsensitiveEnvKey(envObj, 'PATH')
|
|
74
|
+
* console.log(key) // 'Path'
|
|
75
|
+
* console.log(envObj[key]) // 'C:\\Windows'
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* // Not found returns undefined
|
|
79
|
+
* const key = findCaseInsensitiveEnvKey({}, 'MISSING')
|
|
80
|
+
* console.log(key) // undefined
|
|
81
|
+
*/
|
|
82
|
+
export declare function findCaseInsensitiveEnvKey(env: Record<string, string | undefined>, upperEnvVarName: string): string | undefined;
|
package/dist/env.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* Socket Lib - Built with esbuild */
|
|
2
|
-
var
|
|
2
|
+
var f=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var m=(t,n)=>{for(var r in n)f(t,r,{get:n[r],enumerable:!0})},N=(t,n,r,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of y(n))!P.call(t,i)&&i!==r&&f(t,i,{get:()=>n[i],enumerable:!(e=d(n,i))||e.enumerable});return t};var S=t=>N(f({},"__esModule",{value:!0}),t);var b={};m(b,{createEnvProxy:()=>k,envAsBoolean:()=>a,envAsNumber:()=>w,envAsString:()=>C,findCaseInsensitiveEnvKey:()=>u});module.exports=S(b);const A=Number,E=Number.isFinite,O=Number.parseInt,c=String,g=new Set(["APPDATA","COMSPEC","HOME","LOCALAPPDATA","PATH","PATHEXT","PROGRAMFILES","SYSTEMROOT","TEMP","TMP","USERPROFILE","WINDIR"]);function k(t,n){return new Proxy({},{get(r,e){if(typeof e!="string")return;if(n&&e in n)return n[e];if(e in t)return t[e];const i=e.toUpperCase();if(g.has(i)){if(n){const o=u(n,i);if(o!==void 0)return n[o]}const s=u(t,i);if(s!==void 0)return t[s]}},ownKeys(r){return[...new Set([...Object.keys(t),...n?Object.keys(n):[]])]},getOwnPropertyDescriptor(r,e){if(typeof e!="string")return;const i=this.get?.(r,e,r);return i!==void 0?{enumerable:!0,configurable:!0,writable:!0,value:i}:void 0},has(r,e){if(typeof e!="string")return!1;if(n&&e in n||e in t)return!0;const i=e.toUpperCase();return!!(g.has(i)&&(n&&u(n,i)!==void 0||u(t,i)!==void 0))},set(r,e,i){return typeof e=="string"&&n?(n[e]=i,!0):!1}})}function a(t,n=!1){if(typeof t=="string"){const r=t.trim();return r==="1"||r.toLowerCase()==="true"}return t==null?!!n:!!t}function w(t,n=0){const r=O(String(t),10);return(E(r)?r:A(n))||0}function C(t,n=""){return typeof t=="string"?t.trim():t==null?n===""?n:c(n).trim():c(t).trim()}function u(t,n){const r=n.length;for(const e of Object.keys(t))if(e.length===r&&e.toUpperCase()===n)return e}0&&(module.exports={createEnvProxy,envAsBoolean,envAsNumber,envAsString,findCaseInsensitiveEnvKey});
|
|
3
3
|
//# sourceMappingURL=env.js.map
|
package/dist/env.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/env.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @fileoverview Environment variable parsing and conversion utilities.\n * Provides type-safe conversion functions for boolean, number, and string values.\n */\n\nconst NumberCtor = Number\n// IMPORTANT: Do not use destructuring here - use direct assignment instead.\n// tsgo has a bug that incorrectly transpiles destructured exports, resulting in\n// `exports.SomeName = void 0;` which causes runtime errors.\n// See: https://github.com/SocketDev/socket-packageurl-js/issues/3\nconst NumberIsFinite = Number.isFinite\nconst NumberParseInt = Number.parseInt\nconst StringCtor = String\n\n/**\n * Convert an environment variable value to a boolean.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function envAsBoolean(value: unknown, defaultValue = false): boolean {\n if (typeof value === 'string') {\n const trimmed = value.trim()\n return trimmed === '1' || trimmed.toLowerCase() === 'true'\n }\n if (value === null || value === undefined) {\n return !!defaultValue\n }\n return !!value\n}\n\n/**\n * Convert an environment variable value to a number.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function envAsNumber(value: unknown, defaultValue = 0): number {\n const numOrNaN = NumberParseInt(String(value), 10)\n const numMayBeNegZero = NumberIsFinite(numOrNaN)\n ? numOrNaN\n : NumberCtor(defaultValue)\n // Ensure -0 is treated as 0.\n return numMayBeNegZero || 0\n}\n\n/**\n * Convert an environment variable value to a trimmed string.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function envAsString(value: unknown, defaultValue = ''): string {\n if (typeof value === 'string') {\n return value.trim()\n }\n if (value === null || value === undefined) {\n return defaultValue === '' ? defaultValue : StringCtor(defaultValue).trim()\n }\n return StringCtor(value).trim()\n}\n"],
|
|
5
|
-
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,
|
|
6
|
-
"names": ["env_exports", "__export", "envAsBoolean", "envAsNumber", "envAsString", "__toCommonJS", "NumberCtor", "NumberIsFinite", "NumberParseInt", "StringCtor", "value", "defaultValue", "trimmed", "numOrNaN"]
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Environment variable parsing and conversion utilities.\n * Provides type-safe conversion functions for boolean, number, and string values.\n */\n\nconst NumberCtor = Number\n// IMPORTANT: Do not use destructuring here - use direct assignment instead.\n// tsgo has a bug that incorrectly transpiles destructured exports, resulting in\n// `exports.SomeName = void 0;` which causes runtime errors.\n// See: https://github.com/SocketDev/socket-packageurl-js/issues/3\nconst NumberIsFinite = Number.isFinite\nconst NumberParseInt = Number.parseInt\nconst StringCtor = String\n\n// Common environment variables that have case sensitivity issues on Windows.\n// These are checked with case-insensitive matching when exact matches fail.\nconst caseInsensitiveKeys = new Set([\n 'APPDATA',\n 'COMSPEC',\n 'HOME',\n 'LOCALAPPDATA',\n 'PATH',\n 'PATHEXT',\n 'PROGRAMFILES',\n 'SYSTEMROOT',\n 'TEMP',\n 'TMP',\n 'USERPROFILE',\n 'WINDIR',\n])\n\n/**\n * Create a case-insensitive environment variable Proxy for Windows compatibility.\n * On Windows, environment variables are case-insensitive (PATH vs Path vs path).\n * This Proxy provides consistent access regardless of case, with priority given\n * to exact matches, then case-insensitive matches for known vars.\n *\n * **Use Cases:**\n * - Cross-platform test environments needing consistent env var access\n * - Windows compatibility when passing env to child processes\n * - Merging environment overrides while preserving case-insensitive lookups\n *\n * **Performance Note:**\n * Proxy operations have runtime overhead. Only use when Windows case-insensitive\n * access is required. For most use cases, process.env directly is sufficient.\n *\n * @param base - Base environment object (usually process.env)\n * @param overrides - Optional overrides to merge\n * @returns Proxy that handles case-insensitive env var access\n *\n * @example\n * // Create a Proxy with overrides\n * const env = createEnvProxy(process.env, { NODE_ENV: 'test' })\n * console.log(env.PATH) // Works with any case: PATH, Path, path\n * console.log(env.NODE_ENV) // 'test'\n *\n * @example\n * // Pass to child process spawn\n * import { createEnvProxy } from '@socketsecurity/lib/env'\n * import { spawn } from '@socketsecurity/lib/spawn'\n *\n * spawn('node', ['script.js'], {\n * env: createEnvProxy(process.env, { NODE_ENV: 'test' })\n * })\n */\nexport function createEnvProxy(\n base: NodeJS.ProcessEnv,\n overrides?: Record<string, string | undefined>,\n): NodeJS.ProcessEnv {\n return new Proxy(\n {},\n {\n get(_target, prop) {\n if (typeof prop !== 'string') {\n return undefined\n }\n\n // Priority 1: Check overrides for exact match.\n if (overrides && prop in overrides) {\n return overrides[prop]\n }\n\n // Priority 2: Check base for exact match.\n if (prop in base) {\n return base[prop]\n }\n\n // Priority 3: Case-insensitive lookup for known keys.\n const upperProp = prop.toUpperCase()\n if (caseInsensitiveKeys.has(upperProp)) {\n // Check overrides with case variations.\n if (overrides) {\n const key = findCaseInsensitiveEnvKey(overrides, upperProp)\n if (key !== undefined) {\n return overrides[key]\n }\n }\n // Check base with case variations.\n const key = findCaseInsensitiveEnvKey(base, upperProp)\n if (key !== undefined) {\n return base[key]\n }\n }\n\n return undefined\n },\n\n ownKeys(_target) {\n const keys = new Set<string>([\n ...Object.keys(base),\n ...(overrides ? Object.keys(overrides) : []),\n ])\n return [...keys]\n },\n\n getOwnPropertyDescriptor(_target, prop) {\n if (typeof prop !== 'string') {\n return undefined\n }\n\n // Use the same lookup logic as get().\n const value = this.get?.(_target, prop, _target)\n return value !== undefined\n ? {\n enumerable: true,\n configurable: true,\n writable: true,\n value,\n }\n : undefined\n },\n\n has(_target, prop) {\n if (typeof prop !== 'string') {\n return false\n }\n\n // Check overrides.\n if (overrides && prop in overrides) {\n return true\n }\n\n // Check base.\n if (prop in base) {\n return true\n }\n\n // Case-insensitive check.\n const upperProp = prop.toUpperCase()\n if (caseInsensitiveKeys.has(upperProp)) {\n if (\n overrides &&\n findCaseInsensitiveEnvKey(overrides, upperProp) !== undefined\n ) {\n return true\n }\n if (findCaseInsensitiveEnvKey(base, upperProp) !== undefined) {\n return true\n }\n }\n\n return false\n },\n\n set(_target, prop, value) {\n if (typeof prop === 'string' && overrides) {\n overrides[prop] = value\n return true\n }\n return false\n },\n },\n ) as NodeJS.ProcessEnv\n}\n\n/**\n * Convert an environment variable value to a boolean.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function envAsBoolean(value: unknown, defaultValue = false): boolean {\n if (typeof value === 'string') {\n const trimmed = value.trim()\n return trimmed === '1' || trimmed.toLowerCase() === 'true'\n }\n if (value === null || value === undefined) {\n return !!defaultValue\n }\n return !!value\n}\n\n/**\n * Convert an environment variable value to a number.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function envAsNumber(value: unknown, defaultValue = 0): number {\n const numOrNaN = NumberParseInt(String(value), 10)\n const numMayBeNegZero = NumberIsFinite(numOrNaN)\n ? numOrNaN\n : NumberCtor(defaultValue)\n // Ensure -0 is treated as 0.\n return numMayBeNegZero || 0\n}\n\n/**\n * Convert an environment variable value to a trimmed string.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function envAsString(value: unknown, defaultValue = ''): string {\n if (typeof value === 'string') {\n return value.trim()\n }\n if (value === null || value === undefined) {\n return defaultValue === '' ? defaultValue : StringCtor(defaultValue).trim()\n }\n return StringCtor(value).trim()\n}\n\n/**\n * Find a case-insensitive environment variable key match.\n * Searches for an environment variable key that matches the given uppercase name,\n * using optimized fast-path checks to minimize expensive toUpperCase() calls.\n *\n * **Use Cases:**\n * - Finding PATH when env object has \"Path\" or \"path\"\n * - Cross-platform env var access where case may vary\n * - Custom case-insensitive env lookups\n *\n * **Performance:**\n * - Fast path: Checks length first (O(1)) before toUpperCase (expensive)\n * - Only converts to uppercase when length matches\n * - Early exit on first match\n *\n * @param env - Environment object or env-like record to search\n * @param upperEnvVarName - Uppercase environment variable name to find (e.g., 'PATH')\n * @returns The actual key from env that matches (e.g., 'Path'), or undefined\n *\n * @example\n * // Find PATH regardless of case\n * const envObj = { Path: 'C:\\\\Windows', NODE_ENV: 'test' }\n * const key = findCaseInsensitiveEnvKey(envObj, 'PATH')\n * console.log(key) // 'Path'\n * console.log(envObj[key]) // 'C:\\\\Windows'\n *\n * @example\n * // Not found returns undefined\n * const key = findCaseInsensitiveEnvKey({}, 'MISSING')\n * console.log(key) // undefined\n */\nexport function findCaseInsensitiveEnvKey(\n env: Record<string, string | undefined>,\n upperEnvVarName: string,\n): string | undefined {\n const targetLength = upperEnvVarName.length\n for (const key of Object.keys(env)) {\n // Fast path: bail early if lengths don't match.\n if (key.length !== targetLength) {\n continue\n }\n // Only call toUpperCase if length matches.\n if (key.toUpperCase() === upperEnvVarName) {\n return key\n }\n }\n return undefined\n}\n"],
|
|
5
|
+
"mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,EAAA,iBAAAC,EAAA,gBAAAC,EAAA,gBAAAC,EAAA,8BAAAC,IAAA,eAAAC,EAAAP,GAKA,MAAMQ,EAAa,OAKbC,EAAiB,OAAO,SACxBC,EAAiB,OAAO,SACxBC,EAAa,OAIbC,EAAsB,IAAI,IAAI,CAClC,UACA,UACA,OACA,eACA,OACA,UACA,eACA,aACA,OACA,MACA,cACA,QACF,CAAC,EAoCM,SAASV,EACdW,EACAC,EACmB,CACnB,OAAO,IAAI,MACT,CAAC,EACD,CACE,IAAIC,EAASC,EAAM,CACjB,GAAI,OAAOA,GAAS,SAClB,OAIF,GAAIF,GAAaE,KAAQF,EACvB,OAAOA,EAAUE,CAAI,EAIvB,GAAIA,KAAQH,EACV,OAAOA,EAAKG,CAAI,EAIlB,MAAMC,EAAYD,EAAK,YAAY,EACnC,GAAIJ,EAAoB,IAAIK,CAAS,EAAG,CAEtC,GAAIH,EAAW,CACb,MAAMI,EAAMZ,EAA0BQ,EAAWG,CAAS,EAC1D,GAAIC,IAAQ,OACV,OAAOJ,EAAUI,CAAG,CAExB,CAEA,MAAMA,EAAMZ,EAA0BO,EAAMI,CAAS,EACrD,GAAIC,IAAQ,OACV,OAAOL,EAAKK,CAAG,CAEnB,CAGF,EAEA,QAAQH,EAAS,CAKf,MAAO,CAAC,GAJK,IAAI,IAAY,CAC3B,GAAG,OAAO,KAAKF,CAAI,EACnB,GAAIC,EAAY,OAAO,KAAKA,CAAS,EAAI,CAAC,CAC5C,CAAC,CACc,CACjB,EAEA,yBAAyBC,EAASC,EAAM,CACtC,GAAI,OAAOA,GAAS,SAClB,OAIF,MAAMG,EAAQ,KAAK,MAAMJ,EAASC,EAAMD,CAAO,EAC/C,OAAOI,IAAU,OACb,CACE,WAAY,GACZ,aAAc,GACd,SAAU,GACV,MAAAA,CACF,EACA,MACN,EAEA,IAAIJ,EAASC,EAAM,CACjB,GAAI,OAAOA,GAAS,SAClB,MAAO,GAST,GALIF,GAAaE,KAAQF,GAKrBE,KAAQH,EACV,MAAO,GAIT,MAAMI,EAAYD,EAAK,YAAY,EACnC,MAAI,GAAAJ,EAAoB,IAAIK,CAAS,IAEjCH,GACAR,EAA0BQ,EAAWG,CAAS,IAAM,QAIlDX,EAA0BO,EAAMI,CAAS,IAAM,QAMvD,EAEA,IAAIF,EAASC,EAAMG,EAAO,CACxB,OAAI,OAAOH,GAAS,UAAYF,GAC9BA,EAAUE,CAAI,EAAIG,EACX,IAEF,EACT,CACF,CACF,CACF,CAMO,SAAShB,EAAagB,EAAgBC,EAAe,GAAgB,CAC1E,GAAI,OAAOD,GAAU,SAAU,CAC7B,MAAME,EAAUF,EAAM,KAAK,EAC3B,OAAOE,IAAY,KAAOA,EAAQ,YAAY,IAAM,MACtD,CACA,OAAIF,GAAU,KACL,CAAC,CAACC,EAEJ,CAAC,CAACD,CACX,CAMO,SAASf,EAAYe,EAAgBC,EAAe,EAAW,CACpE,MAAME,EAAWZ,EAAe,OAAOS,CAAK,EAAG,EAAE,EAKjD,OAJwBV,EAAea,CAAQ,EAC3CA,EACAd,EAAWY,CAAY,IAED,CAC5B,CAMO,SAASf,EAAYc,EAAgBC,EAAe,GAAY,CACrE,OAAI,OAAOD,GAAU,SACZA,EAAM,KAAK,EAEhBA,GAAU,KACLC,IAAiB,GAAKA,EAAeT,EAAWS,CAAY,EAAE,KAAK,EAErET,EAAWQ,CAAK,EAAE,KAAK,CAChC,CAiCO,SAASb,EACdiB,EACAC,EACoB,CACpB,MAAMC,EAAeD,EAAgB,OACrC,UAAWN,KAAO,OAAO,KAAKK,CAAG,EAE/B,GAAIL,EAAI,SAAWO,GAIfP,EAAI,YAAY,IAAMM,EACxB,OAAON,CAIb",
|
|
6
|
+
"names": ["env_exports", "__export", "createEnvProxy", "envAsBoolean", "envAsNumber", "envAsString", "findCaseInsensitiveEnvKey", "__toCommonJS", "NumberCtor", "NumberIsFinite", "NumberParseInt", "StringCtor", "caseInsensitiveKeys", "base", "overrides", "_target", "prop", "upperProp", "key", "value", "defaultValue", "trimmed", "numOrNaN", "env", "upperEnvVarName", "targetLength"]
|
|
7
7
|
}
|
package/dist/fs.d.ts
CHANGED
|
@@ -585,6 +585,13 @@ export declare function readJson(filepath: PathLike, options?: ReadJsonOptions |
|
|
|
585
585
|
*/
|
|
586
586
|
/*@__NO_SIDE_EFFECTS__*/
|
|
587
587
|
export declare function readJsonSync(filepath: PathLike, options?: ReadJsonOptions | string | undefined): import("./json").JsonValue;
|
|
588
|
+
/**
|
|
589
|
+
* Invalidate the cached allowed directories.
|
|
590
|
+
* Called automatically by the paths/rewire module when paths are overridden in tests.
|
|
591
|
+
*
|
|
592
|
+
* @internal Used for test rewiring
|
|
593
|
+
*/
|
|
594
|
+
export declare function invalidatePathCache(): void;
|
|
588
595
|
/**
|
|
589
596
|
* Safely delete a file or directory asynchronously with built-in protections.
|
|
590
597
|
* Uses `del` for safer deletion that prevents removing cwd and above by default.
|
package/dist/fs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* Socket Lib - Built with esbuild */
|
|
2
|
-
var
|
|
3
|
-
`,s!==void 0?s:!0,c,a);await f.promises.writeFile(n,
|
|
4
|
-
`,s!==void 0?s:!0,c,a);f.writeFileSync(n,
|
|
2
|
+
var x=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var N=(n,e)=>{for(var t in e)x(n,t,{get:e[t],enumerable:!0})},$=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of q(e))!C.call(n,o)&&o!==t&&x(n,o,{get:()=>e[o],enumerable:!(i=T(e,o))||i.enumerable});return n};var V=n=>$(x({},"__esModule",{value:!0}),n);var ue={};N(ue,{findUp:()=>G,findUpSync:()=>M,invalidatePathCache:()=>I,isDir:()=>z,isDirEmptySync:()=>j,isDirSync:()=>K,isSymLinkSync:()=>H,readDirNames:()=>X,readDirNamesSync:()=>Y,readFileBinary:()=>Z,readFileBinarySync:()=>ne,readFileUtf8:()=>ee,readFileUtf8Sync:()=>te,readJson:()=>ie,readJsonSync:()=>re,safeDelete:()=>oe,safeDeleteSync:()=>se,safeReadFile:()=>ae,safeReadFileSync:()=>ce,safeStats:()=>W,safeStatsSync:()=>B,uniqueSync:()=>de,validateFiles:()=>Q,writeJson:()=>fe,writeJsonSync:()=>le});module.exports=V(ue);var D=require("#constants/process"),m=require("./arrays"),S=require("./globs"),R=require("./json"),P=require("./objects"),u=require("./path"),k=require("./paths/rewire"),L=require("./sorts");const w=(0,D.getAbortSignal)(),E=(0,P.objectFreeze)({__proto__:null,force:!0,maxRetries:3,recursive:!0,retryDelay:200});let b;function d(){return b===void 0&&(b=require("node:fs")),b}let v;function _(){return v===void 0&&(v=require("node:path")),v}function A(n,e,t){const{ignore:i,includeEmpty:o=!0,sort:s=!0}={__proto__:null,...t},c=_(),a=n.filter(r=>r.isDirectory()&&(o||!j(c.join(e||r.parentPath,r.name),{ignore:i}))).map(r=>r.name);return s?a.sort(L.naturalCompare):a}function J(n,e,t,i,o=2){const s=t?e:"";return`${JSON.stringify(n,i,o).replace(/\n/g,e)}${s}`}async function G(n,e){const{cwd:t=process.cwd(),signal:i=w}={__proto__:null,...e};let{onlyDirectories:o=!1,onlyFiles:s=!0}={__proto__:null,...e};o&&(s=!1),s&&(o=!1);const c=d(),a=_();let r=a.resolve(t);const{root:f}=a.parse(r),g=(0,m.isArray)(n)?n:[n];for(;r&&r!==f;){for(const y of g){if(i?.aborted)return;const l=a.join(r,y);try{const p=await c.promises.stat(l);if(!o&&p.isFile())return(0,u.normalizePath)(l);if(!s&&p.isDirectory())return(0,u.normalizePath)(l)}catch{}}r=a.dirname(r)}}function M(n,e){const{cwd:t=process.cwd(),stopAt:i}={__proto__:null,...e};let{onlyDirectories:o=!1,onlyFiles:s=!0}={__proto__:null,...e};o&&(s=!1),s&&(o=!1);const c=d(),a=_();let r=a.resolve(t);const{root:f}=a.parse(r),g=i?a.resolve(i):void 0,y=(0,m.isArray)(n)?n:[n];for(;r&&r!==f;){if(g&&r===g){for(const l of y){const p=a.join(r,l);try{const h=c.statSync(p);if(!o&&h.isFile())return(0,u.normalizePath)(p);if(!s&&h.isDirectory())return(0,u.normalizePath)(p)}catch{}}return}for(const l of y){const p=a.join(r,l);try{const h=c.statSync(p);if(!o&&h.isFile())return(0,u.normalizePath)(p);if(!s&&h.isDirectory())return(0,u.normalizePath)(p)}catch{}}r=a.dirname(r)}}async function z(n){return!!(await W(n))?.isDirectory()}function K(n){return!!B(n)?.isDirectory()}function j(n,e){const{ignore:t=S.defaultIgnore}={__proto__:null,...e},i=d();try{const o=i.readdirSync(n),{length:s}=o;if(s===0)return!0;const c=(0,S.getGlobMatcher)(t,{cwd:(0,u.pathLikeToString)(n)});let a=0;for(let r=0;r<s;r+=1){const f=o[r];f&&c(f)&&(a+=1)}return a===s}catch{return!1}}function H(n){const e=d();try{return e.lstatSync(n).isSymbolicLink()}catch{}return!1}function Q(n){const e=d(),t=[],i=[],{R_OK:o}=e.constants;for(const s of n)try{e.accessSync(s,o),t.push(s)}catch{i.push(s)}return{__proto__:null,validPaths:t,invalidPaths:i}}async function X(n,e){const t=d();try{return A(await t.promises.readdir(n,{__proto__:null,encoding:"utf8",withFileTypes:!0}),String(n),e)}catch{}return[]}function Y(n,e){const t=d();try{return A(t.readdirSync(n,{__proto__:null,encoding:"utf8",withFileTypes:!0}),String(n),e)}catch{}return[]}async function Z(n,e){const t=typeof e=="string"?{encoding:e}:e;return await d().promises.readFile(n,{signal:w,...t,encoding:null})}async function ee(n,e){const t=typeof e=="string"?{encoding:e}:e;return await d().promises.readFile(n,{signal:w,...t,encoding:"utf8"})}function ne(n,e){const t=typeof e=="string"?{encoding:e}:e;return d().readFileSync(n,{...t,encoding:null})}function te(n,e){const t=typeof e=="string"?{encoding:e}:e;return d().readFileSync(n,{...t,encoding:"utf8"})}async function ie(n,e){const t=typeof e=="string"?{encoding:e}:e,{reviver:i,throws:o,...s}={__proto__:null,...t},c=o===void 0||!!o,a=d();let r="";try{r=await a.promises.readFile(n,{__proto__:null,encoding:"utf8",...s})}catch(f){if(c)throw f;return}return(0,R.jsonParse)(r,{filepath:String(n),reviver:i,throws:c})}function re(n,e){const t=typeof e=="string"?{encoding:e}:e,{reviver:i,throws:o,...s}={__proto__:null,...t},c=o===void 0||!!o,a=d();let r="";try{r=a.readFileSync(n,{__proto__:null,encoding:"utf8",...s})}catch(f){if(c)throw f;return}return(0,R.jsonParse)(r,{filepath:String(n),reviver:i,throws:c})}let O;function U(){if(O===void 0){const n=_(),{getOsTmpDir:e,getSocketCacacheDir:t,getSocketUserDir:i}=require("#lib/paths");O=[n.resolve(e()),n.resolve(t()),n.resolve(i())]}return O}function I(){O=void 0}(0,k.registerCacheInvalidation)(I);async function oe(n,e){const t=require("./external/del"),{deleteAsync:i}=t,o={__proto__:null,...e},s=(0,m.isArray)(n)?n.map(u.pathLikeToString):[(0,u.pathLikeToString)(n)];let c=o.force!==!1;if(!c&&s.length>0){const a=_(),r=U();s.every(g=>{const y=a.resolve(g);for(const l of r){const p=y.startsWith(l+a.sep)||y===l,F=a.relative(l,y).startsWith("..");if(p&&!F)return!0}return!1})&&(c=!0)}await i(s,{concurrency:o.maxRetries||E.maxRetries,dryRun:!1,force:c,onlyFiles:!1})}function se(n,e){const t=require("./external/del"),{deleteSync:i}=t,o={__proto__:null,...e},s=(0,m.isArray)(n)?n.map(u.pathLikeToString):[(0,u.pathLikeToString)(n)];let c=o.force!==!1;if(!c&&s.length>0){const a=_(),r=U();s.every(g=>{const y=a.resolve(g);for(const l of r){const p=y.startsWith(l+a.sep)||y===l,F=a.relative(l,y).startsWith("..");if(p&&!F)return!0}return!1})&&(c=!0)}i(s,{concurrency:o.maxRetries||E.maxRetries,dryRun:!1,force:c,onlyFiles:!1})}async function ae(n,e){const t=typeof e=="string"?{encoding:e}:e,i=d();try{return await i.promises.readFile(n,{signal:w,...t})}catch{}}async function W(n){const e=d();try{return await e.promises.stat(n)}catch{}}function B(n,e){const t=typeof e=="string"?{encoding:e}:e,i=d();try{return i.statSync(n,{__proto__:null,throwIfNoEntry:!1,...t})}catch{}}function ce(n,e){const t=typeof e=="string"?{encoding:e}:e,i=d();try{return i.readFileSync(n,{__proto__:null,...t})}catch{}}function de(n){const e=d(),t=_(),i=String(n);if(!e.existsSync(i))return(0,u.normalizePath)(i);const o=t.dirname(i),s=t.extname(i),c=t.basename(i,s);let a=1,r;do r=t.join(o,`${c}-${a}${s}`),a++;while(e.existsSync(r));return(0,u.normalizePath)(r)}async function fe(n,e,t){const i=typeof t=="string"?{encoding:t}:t,{EOL:o,finalEOL:s,replacer:c,spaces:a,...r}={__proto__:null,...i},f=d(),g=J(e,o||`
|
|
3
|
+
`,s!==void 0?s:!0,c,a);await f.promises.writeFile(n,g,{encoding:"utf8",...r,__proto__:null})}function le(n,e,t){const i=typeof t=="string"?{encoding:t}:t,{EOL:o,finalEOL:s,replacer:c,spaces:a,...r}={__proto__:null,...i},f=d(),g=J(e,o||`
|
|
4
|
+
`,s!==void 0?s:!0,c,a);f.writeFileSync(n,g,{encoding:"utf8",...r,__proto__:null})}0&&(module.exports={findUp,findUpSync,invalidatePathCache,isDir,isDirEmptySync,isDirSync,isSymLinkSync,readDirNames,readDirNamesSync,readFileBinary,readFileBinarySync,readFileUtf8,readFileUtf8Sync,readJson,readJsonSync,safeDelete,safeDeleteSync,safeReadFile,safeReadFileSync,safeStats,safeStatsSync,uniqueSync,validateFiles,writeJson,writeJsonSync});
|
|
5
5
|
//# sourceMappingURL=fs.js.map
|