@socketsecurity/lib 1.3.2 → 1.3.4
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 +20 -0
- package/dist/abort.js +1 -60
- package/dist/abort.js.map +2 -2
- package/dist/agent.js +1 -289
- package/dist/agent.js.map +2 -2
- package/dist/ansi.js +1 -60
- package/dist/ansi.js.map +2 -2
- package/dist/argv/flags.js +1 -282
- package/dist/argv/flags.js.map +2 -2
- package/dist/argv/parse.js +1 -171
- package/dist/argv/parse.js.map +2 -2
- package/dist/arrays.js +1 -85
- package/dist/arrays.js.map +2 -2
- package/dist/bin.js +1 -402
- package/dist/bin.js.map +2 -2
- package/dist/cacache.js +1 -137
- package/dist/cacache.js.map +2 -2
- package/dist/cache-with-ttl.js +1 -223
- package/dist/cache-with-ttl.js.map +2 -2
- package/dist/constants/agents.js +1 -126
- package/dist/constants/agents.js.map +2 -2
- package/dist/constants/core.js +2 -57
- package/dist/constants/core.js.map +2 -2
- package/dist/constants/encoding.js +1 -48
- package/dist/constants/encoding.js.map +2 -2
- package/dist/constants/github.js +1 -30
- package/dist/constants/github.js.map +2 -2
- package/dist/constants/licenses.js +1 -66
- package/dist/constants/licenses.js.map +2 -2
- package/dist/constants/node.d.ts +2 -3
- package/dist/constants/node.js +1 -171
- package/dist/constants/node.js.map +3 -3
- package/dist/constants/packages.js +1 -128
- package/dist/constants/packages.js.map +2 -2
- package/dist/constants/paths.js +1 -150
- package/dist/constants/paths.js.map +2 -2
- package/dist/constants/platform.js +1 -41
- package/dist/constants/platform.js.map +2 -2
- package/dist/constants/process.js +1 -52
- package/dist/constants/process.js.map +2 -2
- package/dist/constants/socket.js +1 -81
- package/dist/constants/socket.js.map +2 -2
- package/dist/constants/testing.js +1 -36
- package/dist/constants/testing.js.map +2 -2
- package/dist/constants/time.js +1 -39
- package/dist/constants/time.js.map +2 -2
- package/dist/constants/typescript.js +1 -54
- package/dist/constants/typescript.js.map +2 -2
- package/dist/cover/code.js +1 -135
- package/dist/cover/code.js.map +2 -2
- package/dist/cover/formatters.js +11 -101
- package/dist/cover/formatters.js.map +2 -2
- package/dist/cover/type.js +1 -63
- package/dist/cover/type.js.map +2 -2
- package/dist/cover/types.js +1 -15
- package/dist/cover/types.js.map +2 -2
- package/dist/debug.js +2 -343
- package/dist/debug.js.map +2 -2
- package/dist/dlx-binary.js +1 -259
- package/dist/dlx-binary.js.map +2 -2
- package/dist/dlx-package.js +1 -149
- package/dist/dlx-package.js.map +2 -2
- package/dist/dlx.js +1 -166
- package/dist/dlx.js.map +2 -2
- package/dist/download-lock.js +1 -137
- package/dist/download-lock.js.map +2 -2
- package/dist/effects/pulse-frames.js +1 -64
- package/dist/effects/pulse-frames.js.map +2 -2
- package/dist/effects/text-shimmer.js +1 -174
- package/dist/effects/text-shimmer.js.map +2 -2
- package/dist/effects/types.js +1 -15
- package/dist/effects/types.js.map +2 -2
- package/dist/effects/ultra.js +1 -61
- package/dist/effects/ultra.js.map +2 -2
- package/dist/env/appdata.js +1 -28
- package/dist/env/appdata.js.map +2 -2
- package/dist/env/ci.js +1 -29
- package/dist/env/ci.js.map +2 -2
- package/dist/env/comspec.js +1 -28
- package/dist/env/comspec.js.map +2 -2
- package/dist/env/debug.js +1 -28
- package/dist/env/debug.js.map +2 -2
- package/dist/env/getters.js +1 -281
- package/dist/env/getters.js.map +2 -2
- package/dist/env/github-api-url.js +1 -28
- package/dist/env/github-api-url.js.map +2 -2
- package/dist/env/github-base-ref.js +1 -28
- package/dist/env/github-base-ref.js.map +2 -2
- package/dist/env/github-ref-name.js +1 -28
- package/dist/env/github-ref-name.js.map +2 -2
- package/dist/env/github-ref-type.js +1 -28
- package/dist/env/github-ref-type.js.map +2 -2
- package/dist/env/github-repository.js +1 -28
- package/dist/env/github-repository.js.map +2 -2
- package/dist/env/github-server-url.js +1 -28
- package/dist/env/github-server-url.js.map +2 -2
- package/dist/env/github-token.js +1 -28
- package/dist/env/github-token.js.map +2 -2
- package/dist/env/helpers.js +1 -47
- package/dist/env/helpers.js.map +2 -2
- package/dist/env/home.js +1 -28
- package/dist/env/home.js.map +2 -2
- package/dist/env/jest-worker-id.js +1 -28
- package/dist/env/jest-worker-id.js.map +2 -2
- package/dist/env/lang.js +1 -28
- package/dist/env/lang.js.map +2 -2
- package/dist/env/lc-all.js +1 -28
- package/dist/env/lc-all.js.map +2 -2
- package/dist/env/lc-messages.js +1 -28
- package/dist/env/lc-messages.js.map +2 -2
- package/dist/env/localappdata.js +1 -28
- package/dist/env/localappdata.js.map +2 -2
- package/dist/env/node-auth-token.js +1 -28
- package/dist/env/node-auth-token.js.map +2 -2
- package/dist/env/node-env.js +1 -28
- package/dist/env/node-env.js.map +2 -2
- package/dist/env/npm-config-registry.js +1 -28
- package/dist/env/npm-config-registry.js.map +2 -2
- package/dist/env/npm-config-user-agent.js +1 -28
- package/dist/env/npm-config-user-agent.js.map +2 -2
- package/dist/env/npm-lifecycle-event.js +1 -28
- package/dist/env/npm-lifecycle-event.js.map +2 -2
- package/dist/env/npm-registry.js +1 -28
- package/dist/env/npm-registry.js.map +2 -2
- package/dist/env/npm-token.js +1 -28
- package/dist/env/npm-token.js.map +2 -2
- package/dist/env/path.js +1 -28
- package/dist/env/path.js.map +2 -2
- package/dist/env/pre-commit.js +1 -29
- package/dist/env/pre-commit.js.map +2 -2
- package/dist/env/shell.js +1 -28
- package/dist/env/shell.js.map +2 -2
- package/dist/env/socket-accept-risks.js +1 -29
- package/dist/env/socket-accept-risks.js.map +2 -2
- package/dist/env/socket-api-base-url.js +1 -28
- package/dist/env/socket-api-base-url.js.map +2 -2
- package/dist/env/socket-api-proxy.js +1 -28
- package/dist/env/socket-api-proxy.js.map +2 -2
- package/dist/env/socket-api-timeout.js +1 -29
- package/dist/env/socket-api-timeout.js.map +2 -2
- package/dist/env/socket-api-token.js +1 -28
- package/dist/env/socket-api-token.js.map +2 -2
- package/dist/env/socket-cacache-dir.js +1 -28
- package/dist/env/socket-cacache-dir.js.map +2 -2
- package/dist/env/socket-cli-accept-risks.js +1 -31
- package/dist/env/socket-cli-accept-risks.js.map +2 -2
- package/dist/env/socket-cli-api-base-url.js +1 -28
- package/dist/env/socket-cli-api-base-url.js.map +2 -2
- package/dist/env/socket-cli-api-proxy.js +1 -28
- package/dist/env/socket-cli-api-proxy.js.map +2 -2
- package/dist/env/socket-cli-api-timeout.js +1 -29
- package/dist/env/socket-cli-api-timeout.js.map +2 -2
- package/dist/env/socket-cli-api-token.js +1 -28
- package/dist/env/socket-cli-api-token.js.map +2 -2
- package/dist/env/socket-cli-config.js +1 -28
- package/dist/env/socket-cli-config.js.map +2 -2
- package/dist/env/socket-cli-fix.js +1 -28
- package/dist/env/socket-cli-fix.js.map +2 -2
- package/dist/env/socket-cli-no-api-token.js +1 -31
- package/dist/env/socket-cli-no-api-token.js.map +2 -2
- package/dist/env/socket-cli-optimize.js +1 -29
- package/dist/env/socket-cli-optimize.js.map +2 -2
- package/dist/env/socket-cli-org-slug.js +1 -28
- package/dist/env/socket-cli-org-slug.js.map +2 -2
- package/dist/env/socket-cli-shadow-accept-risks.js +1 -31
- package/dist/env/socket-cli-shadow-accept-risks.js.map +2 -2
- package/dist/env/socket-cli-shadow-api-token.js +1 -28
- package/dist/env/socket-cli-shadow-api-token.js.map +2 -2
- package/dist/env/socket-cli-shadow-bin.js +1 -28
- package/dist/env/socket-cli-shadow-bin.js.map +2 -2
- package/dist/env/socket-cli-shadow-progress.js +1 -31
- package/dist/env/socket-cli-shadow-progress.js.map +2 -2
- package/dist/env/socket-cli-shadow-silent.js +1 -31
- package/dist/env/socket-cli-shadow-silent.js.map +2 -2
- package/dist/env/socket-cli-view-all-risks.js +1 -31
- package/dist/env/socket-cli-view-all-risks.js.map +2 -2
- package/dist/env/socket-config.js +1 -28
- package/dist/env/socket-config.js.map +2 -2
- package/dist/env/socket-debug.js +1 -28
- package/dist/env/socket-debug.js.map +2 -2
- package/dist/env/socket-home.js +1 -28
- package/dist/env/socket-home.js.map +2 -2
- package/dist/env/socket-no-api-token.js +1 -29
- package/dist/env/socket-no-api-token.js.map +2 -2
- package/dist/env/socket-npm-registry.js +1 -28
- package/dist/env/socket-npm-registry.js.map +2 -2
- package/dist/env/socket-org-slug.js +1 -28
- package/dist/env/socket-org-slug.js.map +2 -2
- package/dist/env/socket-registry-url.js +1 -28
- package/dist/env/socket-registry-url.js.map +2 -2
- package/dist/env/socket-view-all-risks.js +1 -29
- package/dist/env/socket-view-all-risks.js.map +2 -2
- package/dist/env/temp.js +1 -28
- package/dist/env/temp.js.map +2 -2
- package/dist/env/term.js +1 -28
- package/dist/env/term.js.map +2 -2
- package/dist/env/tmp.js +1 -28
- package/dist/env/tmp.js.map +2 -2
- package/dist/env/tmpdir.js +1 -28
- package/dist/env/tmpdir.js.map +2 -2
- package/dist/env/userprofile.js +1 -28
- package/dist/env/userprofile.js.map +2 -2
- package/dist/env/vitest.js +1 -29
- package/dist/env/vitest.js.map +2 -2
- package/dist/env/xdg-cache-home.js +1 -28
- package/dist/env/xdg-cache-home.js.map +2 -2
- package/dist/env/xdg-config-home.js +1 -28
- package/dist/env/xdg-config-home.js.map +2 -2
- package/dist/env/xdg-data-home.js +1 -28
- package/dist/env/xdg-data-home.js.map +2 -2
- package/dist/env.js +1 -61
- package/dist/env.js.map +2 -2
- package/dist/fs.js +3 -626
- package/dist/fs.js.map +2 -2
- package/dist/functions.js +1 -68
- package/dist/functions.js.map +2 -2
- package/dist/git.js +2 -320
- package/dist/git.js.map +2 -2
- package/dist/github.js +1 -201
- package/dist/github.js.map +2 -2
- package/dist/globs.js +1 -152
- package/dist/globs.js.map +2 -2
- package/dist/http-request.js +1 -313
- package/dist/http-request.js.map +2 -2
- package/dist/index.js +1 -62
- package/dist/index.js.map +2 -2
- package/dist/ipc.js +1 -232
- package/dist/ipc.js.map +2 -2
- package/dist/json.js +1 -73
- package/dist/json.js.map +2 -2
- package/dist/logger.js +1 -1254
- package/dist/logger.js.map +2 -2
- package/dist/maintained-node-versions.js +1 -35
- package/dist/maintained-node-versions.js.map +2 -2
- package/dist/memoization.js +1 -210
- package/dist/memoization.js.map +2 -2
- package/dist/objects.d.ts +0 -3
- package/dist/objects.js +1 -319
- package/dist/objects.js.map +3 -3
- package/dist/packages/editable.js +9 -356
- package/dist/packages/editable.js.map +2 -2
- package/dist/packages/exports.js +1 -162
- package/dist/packages/exports.js.map +2 -2
- package/dist/packages/isolation.js +1 -195
- package/dist/packages/isolation.js.map +2 -2
- package/dist/packages/licenses.js +1 -214
- package/dist/packages/licenses.js.map +2 -2
- package/dist/packages/manifest.js +1 -190
- package/dist/packages/manifest.js.map +2 -2
- package/dist/packages/normalize.js +1 -120
- package/dist/packages/normalize.js.map +2 -2
- package/dist/packages/operations.js +1 -304
- package/dist/packages/operations.js.map +2 -2
- package/dist/packages/paths.js +1 -53
- package/dist/packages/paths.js.map +2 -2
- package/dist/packages/provenance.js +1 -178
- package/dist/packages/provenance.js.map +2 -2
- package/dist/packages/registry.js +1 -28
- package/dist/packages/registry.js.map +2 -2
- package/dist/packages/specs.js +1 -83
- package/dist/packages/specs.js.map +2 -2
- package/dist/packages/validation.js +1 -51
- package/dist/packages/validation.js.map +2 -2
- package/dist/packages.js +1 -129
- package/dist/packages.js.map +2 -2
- package/dist/path.js +1 -448
- package/dist/path.js.map +2 -2
- package/dist/paths.js +1 -143
- package/dist/paths.js.map +2 -2
- package/dist/performance.js +15 -216
- package/dist/performance.js.map +2 -2
- package/dist/promise-queue.js +1 -109
- package/dist/promise-queue.js.map +2 -2
- package/dist/promises.js +1 -269
- package/dist/promises.js.map +2 -2
- package/dist/prompts.js +1 -58
- package/dist/prompts.js.map +2 -2
- package/dist/regexps.js +1 -30
- package/dist/regexps.js.map +2 -2
- package/dist/sea.js +1 -44
- package/dist/sea.js.map +2 -2
- package/dist/shadow.js +1 -58
- package/dist/shadow.js.map +2 -2
- package/dist/signal-exit.js +1 -248
- package/dist/signal-exit.js.map +2 -2
- package/dist/sorts.js +1 -94
- package/dist/sorts.js.map +2 -2
- package/dist/spawn.js +1 -199
- package/dist/spawn.js.map +2 -2
- package/dist/spinner.js +1 -865
- package/dist/spinner.js.map +2 -2
- package/dist/ssri.js +1 -71
- package/dist/ssri.js.map +2 -2
- package/dist/stdio/clear.js +1 -82
- package/dist/stdio/clear.js.map +2 -2
- package/dist/stdio/divider.js +3 -89
- package/dist/stdio/divider.js.map +2 -2
- package/dist/stdio/footer.js +2 -94
- package/dist/stdio/footer.js.map +2 -2
- package/dist/stdio/header.js +2 -100
- package/dist/stdio/header.js.map +2 -2
- package/dist/stdio/mask.js +5 -206
- package/dist/stdio/mask.js.map +2 -2
- package/dist/stdio/progress.js +2 -209
- package/dist/stdio/progress.js.map +2 -2
- package/dist/stdio/prompts.js +1 -88
- package/dist/stdio/prompts.js.map +2 -2
- package/dist/stdio/stderr.js +2 -89
- package/dist/stdio/stderr.js.map +2 -2
- package/dist/stdio/stdout.js +2 -103
- package/dist/stdio/stdout.js.map +2 -2
- package/dist/streams.js +1 -78
- package/dist/streams.js.map +2 -2
- package/dist/strings.js +3 -251
- package/dist/strings.js.map +2 -2
- package/dist/suppress-warnings.js +1 -98
- package/dist/suppress-warnings.js.map +2 -2
- package/dist/tables.js +3 -128
- package/dist/tables.js.map +2 -2
- package/dist/temporary-executor.js +1 -53
- package/dist/temporary-executor.js.map +2 -2
- package/dist/types.js +1 -72
- package/dist/types.js.map +2 -2
- package/dist/url.js +1 -142
- package/dist/url.js.map +2 -2
- package/dist/utils/get-ipc.js +1 -58
- package/dist/utils/get-ipc.js.map +2 -2
- package/dist/validation/json-parser.js +1 -127
- package/dist/validation/json-parser.js.map +2 -2
- package/dist/validation/types.js +1 -15
- package/dist/validation/types.js.map +2 -2
- package/dist/versions.js +1 -153
- package/dist/versions.js.map +2 -2
- package/dist/words.js +1 -50
- package/dist/words.js.map +2 -2
- package/dist/zod.js +1 -27
- package/dist/zod.js.map +2 -2
- package/package.json +4 -4
package/dist/fs.js
CHANGED
|
@@ -1,628 +1,5 @@
|
|
|
1
1
|
/* Socket Lib - Built with esbuild */
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var fs_exports = {};
|
|
20
|
-
__export(fs_exports, {
|
|
21
|
-
findUp: () => findUp,
|
|
22
|
-
findUpSync: () => findUpSync,
|
|
23
|
-
isDir: () => isDir,
|
|
24
|
-
isDirEmptySync: () => isDirEmptySync,
|
|
25
|
-
isDirSync: () => isDirSync,
|
|
26
|
-
isSymLinkSync: () => isSymLinkSync,
|
|
27
|
-
readDirNames: () => readDirNames,
|
|
28
|
-
readDirNamesSync: () => readDirNamesSync,
|
|
29
|
-
readFileBinary: () => readFileBinary,
|
|
30
|
-
readFileBinarySync: () => readFileBinarySync,
|
|
31
|
-
readFileUtf8: () => readFileUtf8,
|
|
32
|
-
readFileUtf8Sync: () => readFileUtf8Sync,
|
|
33
|
-
readJson: () => readJson,
|
|
34
|
-
readJsonSync: () => readJsonSync,
|
|
35
|
-
safeDelete: () => safeDelete,
|
|
36
|
-
safeDeleteSync: () => safeDeleteSync,
|
|
37
|
-
safeReadFile: () => safeReadFile,
|
|
38
|
-
safeReadFileSync: () => safeReadFileSync,
|
|
39
|
-
safeStats: () => safeStats,
|
|
40
|
-
safeStatsSync: () => safeStatsSync,
|
|
41
|
-
uniqueSync: () => uniqueSync,
|
|
42
|
-
validateFiles: () => validateFiles,
|
|
43
|
-
writeJson: () => writeJson,
|
|
44
|
-
writeJsonSync: () => writeJsonSync
|
|
45
|
-
});
|
|
46
|
-
module.exports = __toCommonJS(fs_exports);
|
|
47
|
-
var import_process = require("#constants/process");
|
|
48
|
-
var import_arrays = require("./arrays");
|
|
49
|
-
var import_globs = require("./globs");
|
|
50
|
-
var import_json = require("./json");
|
|
51
|
-
var import_objects = require("./objects");
|
|
52
|
-
var import_path = require("./path");
|
|
53
|
-
var import_sorts = require("./sorts");
|
|
54
|
-
const abortSignal = (0, import_process.getAbortSignal)();
|
|
55
|
-
const defaultRemoveOptions = (0, import_objects.objectFreeze)({
|
|
56
|
-
__proto__: null,
|
|
57
|
-
force: true,
|
|
58
|
-
maxRetries: 3,
|
|
59
|
-
recursive: true,
|
|
60
|
-
retryDelay: 200
|
|
61
|
-
});
|
|
62
|
-
let _fs;
|
|
63
|
-
// @__NO_SIDE_EFFECTS__
|
|
64
|
-
function getFs() {
|
|
65
|
-
if (_fs === void 0) {
|
|
66
|
-
_fs = require("node:fs");
|
|
67
|
-
}
|
|
68
|
-
return _fs;
|
|
69
|
-
}
|
|
70
|
-
let _path;
|
|
71
|
-
// @__NO_SIDE_EFFECTS__
|
|
72
|
-
function getPath() {
|
|
73
|
-
if (_path === void 0) {
|
|
74
|
-
_path = require("node:path");
|
|
75
|
-
}
|
|
76
|
-
return _path;
|
|
77
|
-
}
|
|
78
|
-
let _os;
|
|
79
|
-
// @__NO_SIDE_EFFECTS__
|
|
80
|
-
function getOs() {
|
|
81
|
-
if (_os === void 0) {
|
|
82
|
-
_os = require("node:os");
|
|
83
|
-
}
|
|
84
|
-
return _os;
|
|
85
|
-
}
|
|
86
|
-
// @__NO_SIDE_EFFECTS__
|
|
87
|
-
function innerReadDirNames(dirents, dirname, options) {
|
|
88
|
-
const {
|
|
89
|
-
ignore,
|
|
90
|
-
includeEmpty = true,
|
|
91
|
-
sort = true
|
|
92
|
-
} = { __proto__: null, ...options };
|
|
93
|
-
const path = /* @__PURE__ */ getPath();
|
|
94
|
-
const names = dirents.filter(
|
|
95
|
-
(d) => d.isDirectory() && (includeEmpty || !/* @__PURE__ */ isDirEmptySync(path.join(dirname || d.parentPath, d.name), {
|
|
96
|
-
ignore
|
|
97
|
-
}))
|
|
98
|
-
).map((d) => d.name);
|
|
99
|
-
return sort ? names.sort(import_sorts.naturalCompare) : names;
|
|
100
|
-
}
|
|
101
|
-
// @__NO_SIDE_EFFECTS__
|
|
102
|
-
function stringify(json, EOL, finalEOL, replacer, spaces = 2) {
|
|
103
|
-
const EOF = finalEOL ? EOL : "";
|
|
104
|
-
const str = JSON.stringify(json, replacer, spaces);
|
|
105
|
-
return `${str.replace(/\n/g, EOL)}${EOF}`;
|
|
106
|
-
}
|
|
107
|
-
// @__NO_SIDE_EFFECTS__
|
|
108
|
-
async function findUp(name, options) {
|
|
109
|
-
const { cwd = process.cwd(), signal = abortSignal } = {
|
|
110
|
-
__proto__: null,
|
|
111
|
-
...options
|
|
112
|
-
};
|
|
113
|
-
let { onlyDirectories = false, onlyFiles = true } = {
|
|
114
|
-
__proto__: null,
|
|
115
|
-
...options
|
|
116
|
-
};
|
|
117
|
-
if (onlyDirectories) {
|
|
118
|
-
onlyFiles = false;
|
|
119
|
-
}
|
|
120
|
-
if (onlyFiles) {
|
|
121
|
-
onlyDirectories = false;
|
|
122
|
-
}
|
|
123
|
-
const fs = /* @__PURE__ */ getFs();
|
|
124
|
-
const path = /* @__PURE__ */ getPath();
|
|
125
|
-
let dir = path.resolve(cwd);
|
|
126
|
-
const { root } = path.parse(dir);
|
|
127
|
-
const names = (0, import_arrays.isArray)(name) ? name : [name];
|
|
128
|
-
while (dir && dir !== root) {
|
|
129
|
-
for (const n of names) {
|
|
130
|
-
if (signal?.aborted) {
|
|
131
|
-
return void 0;
|
|
132
|
-
}
|
|
133
|
-
const thePath = path.join(dir, n);
|
|
134
|
-
try {
|
|
135
|
-
const stats = await fs.promises.stat(thePath);
|
|
136
|
-
if (!onlyDirectories && stats.isFile()) {
|
|
137
|
-
return (0, import_path.normalizePath)(thePath);
|
|
138
|
-
}
|
|
139
|
-
if (!onlyFiles && stats.isDirectory()) {
|
|
140
|
-
return (0, import_path.normalizePath)(thePath);
|
|
141
|
-
}
|
|
142
|
-
} catch {
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
dir = path.dirname(dir);
|
|
146
|
-
}
|
|
147
|
-
return void 0;
|
|
148
|
-
}
|
|
149
|
-
// @__NO_SIDE_EFFECTS__
|
|
150
|
-
function findUpSync(name, options) {
|
|
151
|
-
const { cwd = process.cwd(), stopAt } = {
|
|
152
|
-
__proto__: null,
|
|
153
|
-
...options
|
|
154
|
-
};
|
|
155
|
-
let { onlyDirectories = false, onlyFiles = true } = {
|
|
156
|
-
__proto__: null,
|
|
157
|
-
...options
|
|
158
|
-
};
|
|
159
|
-
if (onlyDirectories) {
|
|
160
|
-
onlyFiles = false;
|
|
161
|
-
}
|
|
162
|
-
if (onlyFiles) {
|
|
163
|
-
onlyDirectories = false;
|
|
164
|
-
}
|
|
165
|
-
const fs = /* @__PURE__ */ getFs();
|
|
166
|
-
const path = /* @__PURE__ */ getPath();
|
|
167
|
-
let dir = path.resolve(cwd);
|
|
168
|
-
const { root } = path.parse(dir);
|
|
169
|
-
const stopDir = stopAt ? path.resolve(stopAt) : void 0;
|
|
170
|
-
const names = (0, import_arrays.isArray)(name) ? name : [name];
|
|
171
|
-
while (dir && dir !== root) {
|
|
172
|
-
if (stopDir && dir === stopDir) {
|
|
173
|
-
for (const n of names) {
|
|
174
|
-
const thePath = path.join(dir, n);
|
|
175
|
-
try {
|
|
176
|
-
const stats = fs.statSync(thePath);
|
|
177
|
-
if (!onlyDirectories && stats.isFile()) {
|
|
178
|
-
return (0, import_path.normalizePath)(thePath);
|
|
179
|
-
}
|
|
180
|
-
if (!onlyFiles && stats.isDirectory()) {
|
|
181
|
-
return (0, import_path.normalizePath)(thePath);
|
|
182
|
-
}
|
|
183
|
-
} catch {
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return void 0;
|
|
187
|
-
}
|
|
188
|
-
for (const n of names) {
|
|
189
|
-
const thePath = path.join(dir, n);
|
|
190
|
-
try {
|
|
191
|
-
const stats = fs.statSync(thePath);
|
|
192
|
-
if (!onlyDirectories && stats.isFile()) {
|
|
193
|
-
return (0, import_path.normalizePath)(thePath);
|
|
194
|
-
}
|
|
195
|
-
if (!onlyFiles && stats.isDirectory()) {
|
|
196
|
-
return (0, import_path.normalizePath)(thePath);
|
|
197
|
-
}
|
|
198
|
-
} catch {
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
dir = path.dirname(dir);
|
|
202
|
-
}
|
|
203
|
-
return void 0;
|
|
204
|
-
}
|
|
205
|
-
// @__NO_SIDE_EFFECTS__
|
|
206
|
-
async function isDir(filepath) {
|
|
207
|
-
return !!(await /* @__PURE__ */ safeStats(filepath))?.isDirectory();
|
|
208
|
-
}
|
|
209
|
-
// @__NO_SIDE_EFFECTS__
|
|
210
|
-
function isDirSync(filepath) {
|
|
211
|
-
return !!(/* @__PURE__ */ safeStatsSync(filepath))?.isDirectory();
|
|
212
|
-
}
|
|
213
|
-
// @__NO_SIDE_EFFECTS__
|
|
214
|
-
function isDirEmptySync(dirname, options) {
|
|
215
|
-
const { ignore = import_globs.defaultIgnore } = {
|
|
216
|
-
__proto__: null,
|
|
217
|
-
...options
|
|
218
|
-
};
|
|
219
|
-
const fs = /* @__PURE__ */ getFs();
|
|
220
|
-
try {
|
|
221
|
-
const files = fs.readdirSync(dirname);
|
|
222
|
-
const { length } = files;
|
|
223
|
-
if (length === 0) {
|
|
224
|
-
return true;
|
|
225
|
-
}
|
|
226
|
-
const matcher = (0, import_globs.getGlobMatcher)(
|
|
227
|
-
ignore,
|
|
228
|
-
{
|
|
229
|
-
cwd: (0, import_path.pathLikeToString)(dirname)
|
|
230
|
-
}
|
|
231
|
-
);
|
|
232
|
-
let ignoredCount = 0;
|
|
233
|
-
for (let i = 0; i < length; i += 1) {
|
|
234
|
-
const file = files[i];
|
|
235
|
-
if (file && matcher(file)) {
|
|
236
|
-
ignoredCount += 1;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
return ignoredCount === length;
|
|
240
|
-
} catch {
|
|
241
|
-
return false;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
// @__NO_SIDE_EFFECTS__
|
|
245
|
-
function isSymLinkSync(filepath) {
|
|
246
|
-
const fs = /* @__PURE__ */ getFs();
|
|
247
|
-
try {
|
|
248
|
-
return fs.lstatSync(filepath).isSymbolicLink();
|
|
249
|
-
} catch {
|
|
250
|
-
}
|
|
251
|
-
return false;
|
|
252
|
-
}
|
|
253
|
-
// @__NO_SIDE_EFFECTS__
|
|
254
|
-
function validateFiles(filepaths) {
|
|
255
|
-
const fs = /* @__PURE__ */ getFs();
|
|
256
|
-
const validPaths = [];
|
|
257
|
-
const invalidPaths = [];
|
|
258
|
-
const { R_OK } = fs.constants;
|
|
259
|
-
for (const filepath of filepaths) {
|
|
260
|
-
try {
|
|
261
|
-
fs.accessSync(filepath, R_OK);
|
|
262
|
-
validPaths.push(filepath);
|
|
263
|
-
} catch {
|
|
264
|
-
invalidPaths.push(filepath);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
return { __proto__: null, validPaths, invalidPaths };
|
|
268
|
-
}
|
|
269
|
-
// @__NO_SIDE_EFFECTS__
|
|
270
|
-
async function readDirNames(dirname, options) {
|
|
271
|
-
const fs = /* @__PURE__ */ getFs();
|
|
272
|
-
try {
|
|
273
|
-
return /* @__PURE__ */ innerReadDirNames(
|
|
274
|
-
await fs.promises.readdir(dirname, {
|
|
275
|
-
__proto__: null,
|
|
276
|
-
encoding: "utf8",
|
|
277
|
-
withFileTypes: true
|
|
278
|
-
}),
|
|
279
|
-
String(dirname),
|
|
280
|
-
options
|
|
281
|
-
);
|
|
282
|
-
} catch {
|
|
283
|
-
}
|
|
284
|
-
return [];
|
|
285
|
-
}
|
|
286
|
-
// @__NO_SIDE_EFFECTS__
|
|
287
|
-
function readDirNamesSync(dirname, options) {
|
|
288
|
-
const fs = /* @__PURE__ */ getFs();
|
|
289
|
-
try {
|
|
290
|
-
return /* @__PURE__ */ innerReadDirNames(
|
|
291
|
-
fs.readdirSync(dirname, {
|
|
292
|
-
__proto__: null,
|
|
293
|
-
encoding: "utf8",
|
|
294
|
-
withFileTypes: true
|
|
295
|
-
}),
|
|
296
|
-
String(dirname),
|
|
297
|
-
options
|
|
298
|
-
);
|
|
299
|
-
} catch {
|
|
300
|
-
}
|
|
301
|
-
return [];
|
|
302
|
-
}
|
|
303
|
-
// @__NO_SIDE_EFFECTS__
|
|
304
|
-
async function readFileBinary(filepath, options) {
|
|
305
|
-
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
306
|
-
const fs = /* @__PURE__ */ getFs();
|
|
307
|
-
return await fs.promises.readFile(filepath, {
|
|
308
|
-
signal: abortSignal,
|
|
309
|
-
...opts,
|
|
310
|
-
encoding: null
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
// @__NO_SIDE_EFFECTS__
|
|
314
|
-
async function readFileUtf8(filepath, options) {
|
|
315
|
-
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
316
|
-
const fs = /* @__PURE__ */ getFs();
|
|
317
|
-
return await fs.promises.readFile(filepath, {
|
|
318
|
-
signal: abortSignal,
|
|
319
|
-
...opts,
|
|
320
|
-
encoding: "utf8"
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
// @__NO_SIDE_EFFECTS__
|
|
324
|
-
function readFileBinarySync(filepath, options) {
|
|
325
|
-
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
326
|
-
const fs = /* @__PURE__ */ getFs();
|
|
327
|
-
return fs.readFileSync(filepath, {
|
|
328
|
-
...opts,
|
|
329
|
-
encoding: null
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
// @__NO_SIDE_EFFECTS__
|
|
333
|
-
function readFileUtf8Sync(filepath, options) {
|
|
334
|
-
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
335
|
-
const fs = /* @__PURE__ */ getFs();
|
|
336
|
-
return fs.readFileSync(filepath, {
|
|
337
|
-
...opts,
|
|
338
|
-
encoding: "utf8"
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
// @__NO_SIDE_EFFECTS__
|
|
342
|
-
async function readJson(filepath, options) {
|
|
343
|
-
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
344
|
-
const { reviver, throws, ...fsOptions } = {
|
|
345
|
-
__proto__: null,
|
|
346
|
-
...opts
|
|
347
|
-
};
|
|
348
|
-
const shouldThrow = throws === void 0 || !!throws;
|
|
349
|
-
const fs = /* @__PURE__ */ getFs();
|
|
350
|
-
let content = "";
|
|
351
|
-
try {
|
|
352
|
-
content = await fs.promises.readFile(filepath, {
|
|
353
|
-
__proto__: null,
|
|
354
|
-
encoding: "utf8",
|
|
355
|
-
...fsOptions
|
|
356
|
-
});
|
|
357
|
-
} catch (e) {
|
|
358
|
-
if (shouldThrow) {
|
|
359
|
-
throw e;
|
|
360
|
-
}
|
|
361
|
-
return void 0;
|
|
362
|
-
}
|
|
363
|
-
return (0, import_json.jsonParse)(content, {
|
|
364
|
-
filepath: String(filepath),
|
|
365
|
-
reviver,
|
|
366
|
-
throws: shouldThrow
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
// @__NO_SIDE_EFFECTS__
|
|
370
|
-
function readJsonSync(filepath, options) {
|
|
371
|
-
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
372
|
-
const { reviver, throws, ...fsOptions } = {
|
|
373
|
-
__proto__: null,
|
|
374
|
-
...opts
|
|
375
|
-
};
|
|
376
|
-
const shouldThrow = throws === void 0 || !!throws;
|
|
377
|
-
const fs = /* @__PURE__ */ getFs();
|
|
378
|
-
let content = "";
|
|
379
|
-
try {
|
|
380
|
-
content = fs.readFileSync(filepath, {
|
|
381
|
-
__proto__: null,
|
|
382
|
-
encoding: "utf8",
|
|
383
|
-
...fsOptions
|
|
384
|
-
});
|
|
385
|
-
} catch (e) {
|
|
386
|
-
if (shouldThrow) {
|
|
387
|
-
throw e;
|
|
388
|
-
}
|
|
389
|
-
return void 0;
|
|
390
|
-
}
|
|
391
|
-
return (0, import_json.jsonParse)(content, {
|
|
392
|
-
filepath: String(filepath),
|
|
393
|
-
reviver,
|
|
394
|
-
throws: shouldThrow
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
// @__NO_SIDE_EFFECTS__
|
|
398
|
-
async function safeDelete(filepath, options) {
|
|
399
|
-
const del = require("./external/del");
|
|
400
|
-
const { deleteAsync } = del;
|
|
401
|
-
const opts = { __proto__: null, ...options };
|
|
402
|
-
const patterns = (0, import_arrays.isArray)(filepath) ? filepath.map(import_path.pathLikeToString) : [(0, import_path.pathLikeToString)(filepath)];
|
|
403
|
-
let shouldForce = opts.force !== false;
|
|
404
|
-
if (!shouldForce && patterns.length > 0) {
|
|
405
|
-
const os = /* @__PURE__ */ getOs();
|
|
406
|
-
const path = /* @__PURE__ */ getPath();
|
|
407
|
-
const {
|
|
408
|
-
getSocketCacacheDir,
|
|
409
|
-
getSocketUserDir
|
|
410
|
-
} = require("./paths");
|
|
411
|
-
const tmpDir = os.tmpdir();
|
|
412
|
-
const resolvedTmpDir = path.resolve(tmpDir);
|
|
413
|
-
const cacacheDir = getSocketCacacheDir();
|
|
414
|
-
const resolvedCacacheDir = path.resolve(cacacheDir);
|
|
415
|
-
const socketUserDir = getSocketUserDir();
|
|
416
|
-
const resolvedSocketUserDir = path.resolve(socketUserDir);
|
|
417
|
-
const allInAllowedDirs = patterns.every((pattern) => {
|
|
418
|
-
const resolvedPath = path.resolve(pattern);
|
|
419
|
-
for (const allowedDir of [
|
|
420
|
-
resolvedTmpDir,
|
|
421
|
-
resolvedCacacheDir,
|
|
422
|
-
resolvedSocketUserDir
|
|
423
|
-
]) {
|
|
424
|
-
const isInAllowedDir = resolvedPath.startsWith(allowedDir + path.sep) || resolvedPath === allowedDir;
|
|
425
|
-
const relativePath = path.relative(allowedDir, resolvedPath);
|
|
426
|
-
const isGoingBackward = relativePath.startsWith("..");
|
|
427
|
-
if (isInAllowedDir && !isGoingBackward) {
|
|
428
|
-
return true;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
return false;
|
|
432
|
-
});
|
|
433
|
-
if (allInAllowedDirs) {
|
|
434
|
-
shouldForce = true;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
await deleteAsync(patterns, {
|
|
438
|
-
concurrency: opts.maxRetries || defaultRemoveOptions.maxRetries,
|
|
439
|
-
dryRun: false,
|
|
440
|
-
force: shouldForce,
|
|
441
|
-
onlyFiles: false
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
// @__NO_SIDE_EFFECTS__
|
|
445
|
-
function safeDeleteSync(filepath, options) {
|
|
446
|
-
const del = require("./external/del");
|
|
447
|
-
const { deleteSync } = del;
|
|
448
|
-
const opts = { __proto__: null, ...options };
|
|
449
|
-
const patterns = (0, import_arrays.isArray)(filepath) ? filepath.map(import_path.pathLikeToString) : [(0, import_path.pathLikeToString)(filepath)];
|
|
450
|
-
let shouldForce = opts.force !== false;
|
|
451
|
-
if (!shouldForce && patterns.length > 0) {
|
|
452
|
-
const os = /* @__PURE__ */ getOs();
|
|
453
|
-
const path = /* @__PURE__ */ getPath();
|
|
454
|
-
const {
|
|
455
|
-
getSocketCacacheDir,
|
|
456
|
-
getSocketUserDir
|
|
457
|
-
} = require("./paths");
|
|
458
|
-
const tmpDir = os.tmpdir();
|
|
459
|
-
const resolvedTmpDir = path.resolve(tmpDir);
|
|
460
|
-
const cacacheDir = getSocketCacacheDir();
|
|
461
|
-
const resolvedCacacheDir = path.resolve(cacacheDir);
|
|
462
|
-
const socketUserDir = getSocketUserDir();
|
|
463
|
-
const resolvedSocketUserDir = path.resolve(socketUserDir);
|
|
464
|
-
const allInAllowedDirs = patterns.every((pattern) => {
|
|
465
|
-
const resolvedPath = path.resolve(pattern);
|
|
466
|
-
for (const allowedDir of [
|
|
467
|
-
resolvedTmpDir,
|
|
468
|
-
resolvedCacacheDir,
|
|
469
|
-
resolvedSocketUserDir
|
|
470
|
-
]) {
|
|
471
|
-
const isInAllowedDir = resolvedPath.startsWith(allowedDir + path.sep) || resolvedPath === allowedDir;
|
|
472
|
-
const relativePath = path.relative(allowedDir, resolvedPath);
|
|
473
|
-
const isGoingBackward = relativePath.startsWith("..");
|
|
474
|
-
if (isInAllowedDir && !isGoingBackward) {
|
|
475
|
-
return true;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
return false;
|
|
479
|
-
});
|
|
480
|
-
if (allInAllowedDirs) {
|
|
481
|
-
shouldForce = true;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
deleteSync(patterns, {
|
|
485
|
-
concurrency: opts.maxRetries || defaultRemoveOptions.maxRetries,
|
|
486
|
-
dryRun: false,
|
|
487
|
-
force: shouldForce,
|
|
488
|
-
onlyFiles: false
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
// @__NO_SIDE_EFFECTS__
|
|
492
|
-
async function safeReadFile(filepath, options) {
|
|
493
|
-
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
494
|
-
const fs = /* @__PURE__ */ getFs();
|
|
495
|
-
try {
|
|
496
|
-
return await fs.promises.readFile(filepath, {
|
|
497
|
-
signal: abortSignal,
|
|
498
|
-
...opts
|
|
499
|
-
});
|
|
500
|
-
} catch {
|
|
501
|
-
}
|
|
502
|
-
return void 0;
|
|
503
|
-
}
|
|
504
|
-
// @__NO_SIDE_EFFECTS__
|
|
505
|
-
async function safeStats(filepath) {
|
|
506
|
-
const fs = /* @__PURE__ */ getFs();
|
|
507
|
-
try {
|
|
508
|
-
return await fs.promises.stat(filepath);
|
|
509
|
-
} catch {
|
|
510
|
-
}
|
|
511
|
-
return void 0;
|
|
512
|
-
}
|
|
513
|
-
// @__NO_SIDE_EFFECTS__
|
|
514
|
-
function safeStatsSync(filepath, options) {
|
|
515
|
-
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
516
|
-
const fs = /* @__PURE__ */ getFs();
|
|
517
|
-
try {
|
|
518
|
-
return fs.statSync(filepath, {
|
|
519
|
-
__proto__: null,
|
|
520
|
-
throwIfNoEntry: false,
|
|
521
|
-
...opts
|
|
522
|
-
});
|
|
523
|
-
} catch {
|
|
524
|
-
}
|
|
525
|
-
return void 0;
|
|
526
|
-
}
|
|
527
|
-
// @__NO_SIDE_EFFECTS__
|
|
528
|
-
function safeReadFileSync(filepath, options) {
|
|
529
|
-
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
530
|
-
const fs = /* @__PURE__ */ getFs();
|
|
531
|
-
try {
|
|
532
|
-
return fs.readFileSync(filepath, {
|
|
533
|
-
__proto__: null,
|
|
534
|
-
...opts
|
|
535
|
-
});
|
|
536
|
-
} catch {
|
|
537
|
-
}
|
|
538
|
-
return void 0;
|
|
539
|
-
}
|
|
540
|
-
// @__NO_SIDE_EFFECTS__
|
|
541
|
-
function uniqueSync(filepath) {
|
|
542
|
-
const fs = /* @__PURE__ */ getFs();
|
|
543
|
-
const path = /* @__PURE__ */ getPath();
|
|
544
|
-
const filepathStr = String(filepath);
|
|
545
|
-
if (!fs.existsSync(filepathStr)) {
|
|
546
|
-
return (0, import_path.normalizePath)(filepathStr);
|
|
547
|
-
}
|
|
548
|
-
const dirname = path.dirname(filepathStr);
|
|
549
|
-
const ext = path.extname(filepathStr);
|
|
550
|
-
const basename = path.basename(filepathStr, ext);
|
|
551
|
-
let counter = 1;
|
|
552
|
-
let uniquePath;
|
|
553
|
-
do {
|
|
554
|
-
uniquePath = path.join(dirname, `${basename}-${counter}${ext}`);
|
|
555
|
-
counter++;
|
|
556
|
-
} while (fs.existsSync(uniquePath));
|
|
557
|
-
return (0, import_path.normalizePath)(uniquePath);
|
|
558
|
-
}
|
|
559
|
-
// @__NO_SIDE_EFFECTS__
|
|
560
|
-
async function writeJson(filepath, jsonContent, options) {
|
|
561
|
-
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
562
|
-
const { EOL, finalEOL, replacer, spaces, ...fsOptions } = {
|
|
563
|
-
__proto__: null,
|
|
564
|
-
...opts
|
|
565
|
-
};
|
|
566
|
-
const fs = /* @__PURE__ */ getFs();
|
|
567
|
-
const jsonString = /* @__PURE__ */ stringify(
|
|
568
|
-
jsonContent,
|
|
569
|
-
EOL || "\n",
|
|
570
|
-
finalEOL !== void 0 ? finalEOL : true,
|
|
571
|
-
replacer,
|
|
572
|
-
spaces
|
|
573
|
-
);
|
|
574
|
-
await fs.promises.writeFile(filepath, jsonString, {
|
|
575
|
-
encoding: "utf8",
|
|
576
|
-
...fsOptions,
|
|
577
|
-
__proto__: null
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
// @__NO_SIDE_EFFECTS__
|
|
581
|
-
function writeJsonSync(filepath, jsonContent, options) {
|
|
582
|
-
const opts = typeof options === "string" ? { encoding: options } : options;
|
|
583
|
-
const { EOL, finalEOL, replacer, spaces, ...fsOptions } = {
|
|
584
|
-
__proto__: null,
|
|
585
|
-
...opts
|
|
586
|
-
};
|
|
587
|
-
const fs = /* @__PURE__ */ getFs();
|
|
588
|
-
const jsonString = /* @__PURE__ */ stringify(
|
|
589
|
-
jsonContent,
|
|
590
|
-
EOL || "\n",
|
|
591
|
-
finalEOL !== void 0 ? finalEOL : true,
|
|
592
|
-
replacer,
|
|
593
|
-
spaces
|
|
594
|
-
);
|
|
595
|
-
fs.writeFileSync(filepath, jsonString, {
|
|
596
|
-
encoding: "utf8",
|
|
597
|
-
...fsOptions,
|
|
598
|
-
__proto__: null
|
|
599
|
-
});
|
|
600
|
-
}
|
|
601
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
602
|
-
0 && (module.exports = {
|
|
603
|
-
findUp,
|
|
604
|
-
findUpSync,
|
|
605
|
-
isDir,
|
|
606
|
-
isDirEmptySync,
|
|
607
|
-
isDirSync,
|
|
608
|
-
isSymLinkSync,
|
|
609
|
-
readDirNames,
|
|
610
|
-
readDirNamesSync,
|
|
611
|
-
readFileBinary,
|
|
612
|
-
readFileBinarySync,
|
|
613
|
-
readFileUtf8,
|
|
614
|
-
readFileUtf8Sync,
|
|
615
|
-
readJson,
|
|
616
|
-
readJsonSync,
|
|
617
|
-
safeDelete,
|
|
618
|
-
safeDeleteSync,
|
|
619
|
-
safeReadFile,
|
|
620
|
-
safeReadFileSync,
|
|
621
|
-
safeStats,
|
|
622
|
-
safeStatsSync,
|
|
623
|
-
uniqueSync,
|
|
624
|
-
validateFiles,
|
|
625
|
-
writeJson,
|
|
626
|
-
writeJsonSync
|
|
627
|
-
});
|
|
2
|
+
var P=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var K=(n,e)=>{for(var t in e)P(n,t,{get:e[t],enumerable:!0})},H=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of M(e))!z.call(n,o)&&o!==t&&P(n,o,{get:()=>e[o],enumerable:!(i=G(e,o))||i.enumerable});return n};var Q=n=>H(P({},"__esModule",{value:!0}),n);var me={};K(me,{findUp:()=>X,findUpSync:()=>Y,isDir:()=>Z,isDirEmptySync:()=>B,isDirSync:()=>ee,isSymLinkSync:()=>ne,readDirNames:()=>re,readDirNamesSync:()=>ie,readFileBinary:()=>oe,readFileBinarySync:()=>ae,readFileUtf8:()=>se,readFileUtf8Sync:()=>ce,readJson:()=>de,readJsonSync:()=>fe,safeDelete:()=>le,safeDeleteSync:()=>ue,safeReadFile:()=>pe,safeReadFileSync:()=>ye,safeStats:()=>C,safeStatsSync:()=>N,uniqueSync:()=>ge,validateFiles:()=>te,writeJson:()=>he,writeJsonSync:()=>_e});module.exports=Q(me);var j=require("#constants/process"),S=require("./arrays"),D=require("./globs"),J=require("./json"),A=require("./objects"),l=require("./path"),U=require("./sorts");const w=(0,j.getAbortSignal)(),W=(0,A.objectFreeze)({__proto__:null,force:!0,maxRetries:3,recursive:!0,retryDelay:200});let k;function d(){return k===void 0&&(k=require("node:fs")),k}let L;function O(){return L===void 0&&(L=require("node:path")),L}let E;function I(){return E===void 0&&(E=require("node:os")),E}function q(n,e,t){const{ignore:i,includeEmpty:o=!0,sort:s=!0}={__proto__:null,...t},c=O(),a=n.filter(r=>r.isDirectory()&&(o||!B(c.join(e||r.parentPath,r.name),{ignore:i}))).map(r=>r.name);return s?a.sort(U.naturalCompare):a}function T(n,e,t,i,o=2){const s=t?e:"";return`${JSON.stringify(n,i,o).replace(/\n/g,e)}${s}`}async function X(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=O();let r=a.resolve(t);const{root:f}=a.parse(r),p=(0,S.isArray)(n)?n:[n];for(;r&&r!==f;){for(const h of p){if(i?.aborted)return;const y=a.join(r,h);try{const u=await c.promises.stat(y);if(!o&&u.isFile())return(0,l.normalizePath)(y);if(!s&&u.isDirectory())return(0,l.normalizePath)(y)}catch{}}r=a.dirname(r)}}function Y(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=O();let r=a.resolve(t);const{root:f}=a.parse(r),p=i?a.resolve(i):void 0,h=(0,S.isArray)(n)?n:[n];for(;r&&r!==f;){if(p&&r===p){for(const y of h){const u=a.join(r,y);try{const g=c.statSync(u);if(!o&&g.isFile())return(0,l.normalizePath)(u);if(!s&&g.isDirectory())return(0,l.normalizePath)(u)}catch{}}return}for(const y of h){const u=a.join(r,y);try{const g=c.statSync(u);if(!o&&g.isFile())return(0,l.normalizePath)(u);if(!s&&g.isDirectory())return(0,l.normalizePath)(u)}catch{}}r=a.dirname(r)}}async function Z(n){return!!(await C(n))?.isDirectory()}function ee(n){return!!N(n)?.isDirectory()}function B(n,e){const{ignore:t=D.defaultIgnore}={__proto__:null,...e},i=d();try{const o=i.readdirSync(n),{length:s}=o;if(s===0)return!0;const c=(0,D.getGlobMatcher)(t,{cwd:(0,l.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 ne(n){const e=d();try{return e.lstatSync(n).isSymbolicLink()}catch{}return!1}function te(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 re(n,e){const t=d();try{return q(await t.promises.readdir(n,{__proto__:null,encoding:"utf8",withFileTypes:!0}),String(n),e)}catch{}return[]}function ie(n,e){const t=d();try{return q(t.readdirSync(n,{__proto__:null,encoding:"utf8",withFileTypes:!0}),String(n),e)}catch{}return[]}async function oe(n,e){const t=typeof e=="string"?{encoding:e}:e;return await d().promises.readFile(n,{signal:w,...t,encoding:null})}async function se(n,e){const t=typeof e=="string"?{encoding:e}:e;return await d().promises.readFile(n,{signal:w,...t,encoding:"utf8"})}function ae(n,e){const t=typeof e=="string"?{encoding:e}:e;return d().readFileSync(n,{...t,encoding:null})}function ce(n,e){const t=typeof e=="string"?{encoding:e}:e;return d().readFileSync(n,{...t,encoding:"utf8"})}async function de(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,J.jsonParse)(r,{filepath:String(n),reviver:i,throws:c})}function fe(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,J.jsonParse)(r,{filepath:String(n),reviver:i,throws:c})}async function le(n,e){const t=require("./external/del"),{deleteAsync:i}=t,o={__proto__:null,...e},s=(0,S.isArray)(n)?n.map(l.pathLikeToString):[(0,l.pathLikeToString)(n)];let c=o.force!==!1;if(!c&&s.length>0){const a=I(),r=O(),{getSocketCacacheDir:f,getSocketUserDir:p}=require("./paths"),h=a.tmpdir(),y=r.resolve(h),u=f(),g=r.resolve(u),F=p(),v=r.resolve(F);s.every(x=>{const _=r.resolve(x);for(const m of[y,g,v]){const b=_.startsWith(m+r.sep)||_===m,R=r.relative(m,_).startsWith("..");if(b&&!R)return!0}return!1})&&(c=!0)}await i(s,{concurrency:o.maxRetries||W.maxRetries,dryRun:!1,force:c,onlyFiles:!1})}function ue(n,e){const t=require("./external/del"),{deleteSync:i}=t,o={__proto__:null,...e},s=(0,S.isArray)(n)?n.map(l.pathLikeToString):[(0,l.pathLikeToString)(n)];let c=o.force!==!1;if(!c&&s.length>0){const a=I(),r=O(),{getSocketCacacheDir:f,getSocketUserDir:p}=require("./paths"),h=a.tmpdir(),y=r.resolve(h),u=f(),g=r.resolve(u),F=p(),v=r.resolve(F);s.every(x=>{const _=r.resolve(x);for(const m of[y,g,v]){const b=_.startsWith(m+r.sep)||_===m,R=r.relative(m,_).startsWith("..");if(b&&!R)return!0}return!1})&&(c=!0)}i(s,{concurrency:o.maxRetries||W.maxRetries,dryRun:!1,force:c,onlyFiles:!1})}async function pe(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 C(n){const e=d();try{return await e.promises.stat(n)}catch{}}function N(n,e){const t=typeof e=="string"?{encoding:e}:e,i=d();try{return i.statSync(n,{__proto__:null,throwIfNoEntry:!1,...t})}catch{}}function ye(n,e){const t=typeof e=="string"?{encoding:e}:e,i=d();try{return i.readFileSync(n,{__proto__:null,...t})}catch{}}function ge(n){const e=d(),t=O(),i=String(n);if(!e.existsSync(i))return(0,l.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,l.normalizePath)(r)}async function he(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(),p=T(e,o||`
|
|
3
|
+
`,s!==void 0?s:!0,c,a);await f.promises.writeFile(n,p,{encoding:"utf8",...r,__proto__:null})}function _e(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(),p=T(e,o||`
|
|
4
|
+
`,s!==void 0?s:!0,c,a);f.writeFileSync(n,p,{encoding:"utf8",...r,__proto__:null})}0&&(module.exports={findUp,findUpSync,isDir,isDirEmptySync,isDirSync,isSymLinkSync,readDirNames,readDirNamesSync,readFileBinary,readFileBinarySync,readFileUtf8,readFileUtf8Sync,readJson,readJsonSync,safeDelete,safeDeleteSync,safeReadFile,safeReadFileSync,safeStats,safeStatsSync,uniqueSync,validateFiles,writeJson,writeJsonSync});
|
|
628
5
|
//# sourceMappingURL=fs.js.map
|