aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/node_modules/@actions/io/lib/io-util.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/@actions/io/lib/io-util.js')
-rw-r--r--node_modules/@actions/io/lib/io-util.js89
1 files changed, 65 insertions, 24 deletions
diff --git a/node_modules/@actions/io/lib/io-util.js b/node_modules/@actions/io/lib/io-util.js
index f12e5b0..ac9e715 100644
--- a/node_modules/@actions/io/lib/io-util.js
+++ b/node_modules/@actions/io/lib/io-util.js
@@ -1,7 +1,11 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
+ var desc = Object.getOwnPropertyDescriptor(m, k);
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() { return m[k]; } };
+ }
+ Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
@@ -11,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
}) : function(o, v) {
o["default"] = v;
});
-var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- __setModuleDefault(result, mod);
- return result;
-};
+var __importStar = (this && this.__importStar) || (function () {
+ var ownKeys = function(o) {
+ ownKeys = Object.getOwnPropertyNames || function (o) {
+ var ar = [];
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
+ return ar;
+ };
+ return ownKeys(o);
+ };
+ return function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
+ __setModuleDefault(result, mod);
+ return result;
+ };
+})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
@@ -29,21 +43,49 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
-exports.getCmdPath = exports.tryGetExecutablePath = exports.isRooted = exports.isDirectory = exports.exists = exports.READONLY = exports.UV_FS_O_EXLOCK = exports.IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rm = exports.rename = exports.readlink = exports.readdir = exports.open = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0;
+exports.READONLY = exports.UV_FS_O_EXLOCK = exports.IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rm = exports.rename = exports.readdir = exports.open = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0;
+exports.readlink = readlink;
+exports.exists = exists;
+exports.isDirectory = isDirectory;
+exports.isRooted = isRooted;
+exports.tryGetExecutablePath = tryGetExecutablePath;
+exports.getCmdPath = getCmdPath;
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
_a = fs.promises
// export const {open} = 'fs'
-, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.open = _a.open, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rm = _a.rm, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink;
+, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.open = _a.open, exports.readdir = _a.readdir, exports.rename = _a.rename, exports.rm = _a.rm, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink;
// export const {open} = 'fs'
exports.IS_WINDOWS = process.platform === 'win32';
+/**
+ * Custom implementation of readlink to ensure Windows junctions
+ * maintain trailing backslash for backward compatibility with Node.js < 24
+ *
+ * In Node.js 20, Windows junctions (directory symlinks) always returned paths
+ * with trailing backslashes. Node.js 24 removed this behavior, which breaks
+ * code that relied on this format for path operations.
+ *
+ * This implementation restores the Node 20 behavior by adding a trailing
+ * backslash to all junction results on Windows.
+ */
+function readlink(fsPath) {
+ return __awaiter(this, void 0, void 0, function* () {
+ const result = yield fs.promises.readlink(fsPath);
+ // On Windows, restore Node 20 behavior: add trailing backslash to all results
+ // since junctions on Windows are always directory links
+ if (exports.IS_WINDOWS && !result.endsWith('\\')) {
+ return `${result}\\`;
+ }
+ return result;
+ });
+}
// See https://github.com/nodejs/node/blob/d0153aee367422d0858105abec186da4dff0a0c5/deps/uv/include/uv/win.h#L691
exports.UV_FS_O_EXLOCK = 0x10000000;
exports.READONLY = fs.constants.O_RDONLY;
function exists(fsPath) {
return __awaiter(this, void 0, void 0, function* () {
try {
- yield exports.stat(fsPath);
+ yield (0, exports.stat)(fsPath);
}
catch (err) {
if (err.code === 'ENOENT') {
@@ -54,14 +96,12 @@ function exists(fsPath) {
return true;
});
}
-exports.exists = exists;
-function isDirectory(fsPath, useStat = false) {
- return __awaiter(this, void 0, void 0, function* () {
- const stats = useStat ? yield exports.stat(fsPath) : yield exports.lstat(fsPath);
+function isDirectory(fsPath_1) {
+ return __awaiter(this, arguments, void 0, function* (fsPath, useStat = false) {
+ const stats = useStat ? yield (0, exports.stat)(fsPath) : yield (0, exports.lstat)(fsPath);
return stats.isDirectory();
});
}
-exports.isDirectory = isDirectory;
/**
* On OSX/Linux, true if path starts with '/'. On Windows, true for paths like:
* \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
@@ -77,7 +117,6 @@ function isRooted(p) {
}
return p.startsWith('/');
}
-exports.isRooted = isRooted;
/**
* Best effort attempt to determine whether a file exists and is executable.
* @param filePath file path to check
@@ -89,7 +128,7 @@ function tryGetExecutablePath(filePath, extensions) {
let stats = undefined;
try {
// test file exists
- stats = yield exports.stat(filePath);
+ stats = yield (0, exports.stat)(filePath);
}
catch (err) {
if (err.code !== 'ENOENT') {
@@ -117,7 +156,7 @@ function tryGetExecutablePath(filePath, extensions) {
filePath = originalFilePath + extension;
stats = undefined;
try {
- stats = yield exports.stat(filePath);
+ stats = yield (0, exports.stat)(filePath);
}
catch (err) {
if (err.code !== 'ENOENT') {
@@ -131,7 +170,7 @@ function tryGetExecutablePath(filePath, extensions) {
try {
const directory = path.dirname(filePath);
const upperName = path.basename(filePath).toUpperCase();
- for (const actualName of yield exports.readdir(directory)) {
+ for (const actualName of yield (0, exports.readdir)(directory)) {
if (upperName === actualName.toUpperCase()) {
filePath = path.join(directory, actualName);
break;
@@ -154,7 +193,6 @@ function tryGetExecutablePath(filePath, extensions) {
return '';
});
}
-exports.tryGetExecutablePath = tryGetExecutablePath;
function normalizeSeparators(p) {
p = p || '';
if (exports.IS_WINDOWS) {
@@ -171,13 +209,16 @@ function normalizeSeparators(p) {
// 256 128 64 32 16 8 4 2 1
function isUnixExecutable(stats) {
return ((stats.mode & 1) > 0 ||
- ((stats.mode & 8) > 0 && stats.gid === process.getgid()) ||
- ((stats.mode & 64) > 0 && stats.uid === process.getuid()));
+ ((stats.mode & 8) > 0 &&
+ process.getgid !== undefined &&
+ stats.gid === process.getgid()) ||
+ ((stats.mode & 64) > 0 &&
+ process.getuid !== undefined &&
+ stats.uid === process.getuid()));
}
// Get the path of cmd.exe in windows
function getCmdPath() {
var _a;
return (_a = process.env['COMSPEC']) !== null && _a !== void 0 ? _a : `cmd.exe`;
}
-exports.getCmdPath = getCmdPath;
//# sourceMappingURL=io-util.js.map \ No newline at end of file