summaryrefslogtreecommitdiffstatshomepage
path: root/node_modules/@actions/io/lib/io-util.js
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-02-28 22:23:19 +0100
committerEgor Tensin <egor@tensin.name>2026-02-28 22:28:23 +0100
commitcf0901d753db0bf4d15baf625a6fa537978b03a9 (patch)
tree41ae5e7f9eacdc67b9fa980596c803b9c50ca188 /node_modules/@actions/io/lib/io-util.js
parentupgrade actions/core to version 2 (diff)
downloadcleanup-path-cf0901d753db0bf4d15baf625a6fa537978b03a9.tar.gz
cleanup-path-cf0901d753db0bf4d15baf625a6fa537978b03a9.zip
upgrade actions/core to version 3v4.0.3v4
The relevant changes are in clean.js/restore.js. I'm very, very far away from the entire Javascript infrastructure, and absolutely don't understand why this changes were necessary. Thanks, ChatGPT! Supposedly, this has something to do with the actions/core's transition to ESM or whatever.
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, 22 insertions, 67 deletions
diff --git a/node_modules/@actions/io/lib/io-util.js b/node_modules/@actions/io/lib/io-util.js
index ac9e715..ef0afe3 100644
--- a/node_modules/@actions/io/lib/io-util.js
+++ b/node_modules/@actions/io/lib/io-util.js
@@ -1,37 +1,3 @@
-"use strict";
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = 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];
-}));
-var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
-}) : function(o, v) {
- o["default"] = v;
-});
-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) {
@@ -41,22 +7,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
-var _a;
-Object.defineProperty(exports, "__esModule", { value: true });
-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.rename = _a.rename, exports.rm = _a.rm, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink;
+import * as fs from 'fs';
+import * as path from 'path';
+export const { chmod, copyFile, lstat, mkdir, open, readdir, rename, rm, rmdir, stat, symlink, unlink } = fs.promises;
// export const {open} = 'fs'
-exports.IS_WINDOWS = process.platform === 'win32';
+export const IS_WINDOWS = process.platform === 'win32';
/**
* Custom implementation of readlink to ensure Windows junctions
* maintain trailing backslash for backward compatibility with Node.js < 24
@@ -68,24 +23,24 @@ exports.IS_WINDOWS = process.platform === 'win32';
* This implementation restores the Node 20 behavior by adding a trailing
* backslash to all junction results on Windows.
*/
-function readlink(fsPath) {
+export 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('\\')) {
+ if (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) {
+export const UV_FS_O_EXLOCK = 0x10000000;
+export const READONLY = fs.constants.O_RDONLY;
+export function exists(fsPath) {
return __awaiter(this, void 0, void 0, function* () {
try {
- yield (0, exports.stat)(fsPath);
+ yield stat(fsPath);
}
catch (err) {
if (err.code === 'ENOENT') {
@@ -96,9 +51,9 @@ function exists(fsPath) {
return true;
});
}
-function isDirectory(fsPath_1) {
+export 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);
+ const stats = useStat ? yield stat(fsPath) : yield lstat(fsPath);
return stats.isDirectory();
});
}
@@ -106,12 +61,12 @@ function isDirectory(fsPath_1) {
* 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).
*/
-function isRooted(p) {
+export function isRooted(p) {
p = normalizeSeparators(p);
if (!p) {
throw new Error('isRooted() parameter "p" cannot be empty');
}
- if (exports.IS_WINDOWS) {
+ if (IS_WINDOWS) {
return (p.startsWith('\\') || /^[A-Z]:/i.test(p) // e.g. \ or \hello or \\hello
); // e.g. C: or C:\hello
}
@@ -123,12 +78,12 @@ function isRooted(p) {
* @param extensions additional file extensions to try
* @return if file exists and is executable, returns the file path. otherwise empty string.
*/
-function tryGetExecutablePath(filePath, extensions) {
+export function tryGetExecutablePath(filePath, extensions) {
return __awaiter(this, void 0, void 0, function* () {
let stats = undefined;
try {
// test file exists
- stats = yield (0, exports.stat)(filePath);
+ stats = yield stat(filePath);
}
catch (err) {
if (err.code !== 'ENOENT') {
@@ -137,7 +92,7 @@ function tryGetExecutablePath(filePath, extensions) {
}
}
if (stats && stats.isFile()) {
- if (exports.IS_WINDOWS) {
+ if (IS_WINDOWS) {
// on Windows, test for valid extension
const upperExt = path.extname(filePath).toUpperCase();
if (extensions.some(validExt => validExt.toUpperCase() === upperExt)) {
@@ -156,7 +111,7 @@ function tryGetExecutablePath(filePath, extensions) {
filePath = originalFilePath + extension;
stats = undefined;
try {
- stats = yield (0, exports.stat)(filePath);
+ stats = yield stat(filePath);
}
catch (err) {
if (err.code !== 'ENOENT') {
@@ -165,12 +120,12 @@ function tryGetExecutablePath(filePath, extensions) {
}
}
if (stats && stats.isFile()) {
- if (exports.IS_WINDOWS) {
+ if (IS_WINDOWS) {
// preserve the case of the actual file (since an extension was appended)
try {
const directory = path.dirname(filePath);
const upperName = path.basename(filePath).toUpperCase();
- for (const actualName of yield (0, exports.readdir)(directory)) {
+ for (const actualName of yield readdir(directory)) {
if (upperName === actualName.toUpperCase()) {
filePath = path.join(directory, actualName);
break;
@@ -195,7 +150,7 @@ function tryGetExecutablePath(filePath, extensions) {
}
function normalizeSeparators(p) {
p = p || '';
- if (exports.IS_WINDOWS) {
+ if (IS_WINDOWS) {
// convert slashes on Windows
p = p.replace(/\//g, '\\');
// remove redundant slashes
@@ -217,7 +172,7 @@ function isUnixExecutable(stats) {
stats.uid === process.getuid()));
}
// Get the path of cmd.exe in windows
-function getCmdPath() {
+export function getCmdPath() {
var _a;
return (_a = process.env['COMSPEC']) !== null && _a !== void 0 ? _a : `cmd.exe`;
}