Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion __tests__/cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ describe('cache', () => {

// Mock utils
(utils.getCacheDirectory as jest.Mock).mockReturnValue(mockCacheDir);
(utils.copyDirRecursive as jest.Mock).mockResolvedValue(undefined);
});

describe('restoreCache', () => {
Expand Down
36 changes: 0 additions & 36 deletions __tests__/utils-basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jest.mock('path');
function setupPathAndOSMocks(): void {
jest.resetAllMocks();
(path.join as jest.Mock).mockImplementation((...parts) => parts.join('/'));
(path.dirname as jest.Mock).mockImplementation(p => p.substring(0, p.lastIndexOf('/')));
(os.tmpdir as jest.Mock).mockReturnValue('/tmp');
}

Expand All @@ -36,41 +35,6 @@ describe('utils - Basic Functions', () => {
});
});

describe('getExecutableDirectoryPath', () => {
test('should return directory path when input is a file', () => {
const result = utils.getExecutableDirectoryPath('/usr/bin/task');
expect(result).toBe('/usr/bin');
expect(path.dirname).toHaveBeenCalledWith('/usr/bin/task');
});
});

describe('parseMultilineInput', () => {
test('should handle empty input', () => {
const result = utils.parseMultilineInput('');
expect(result).toEqual([]);
});

test('should handle single line input', () => {
const result = utils.parseMultilineInput('line1');
expect(result).toEqual(['line1']);
});

test('should handle multiline input', () => {
const result = utils.parseMultilineInput('line1\nline2\nline3');
expect(result).toEqual(['line1', 'line2', 'line3']);
});

test('should trim whitespace', () => {
const result = utils.parseMultilineInput(' line1 \n line2 ');
expect(result).toEqual(['line1', 'line2']);
});

test('should skip empty lines', () => {
const result = utils.parseMultilineInput('line1\n\nline2');
expect(result).toEqual(['line1', 'line2']);
});
});

describe('logAndFail', () => {
test('should throw error with message', () => {
expect(() => utils.logAndFail('test error')).toThrow('test error');
Expand Down
107 changes: 0 additions & 107 deletions __tests__/utils-file.test.ts

This file was deleted.

81 changes: 0 additions & 81 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48318,80 +48318,13 @@ const RELEASES_URL = 'https://github.com/go-task/task/releases/download';




/**
* Get the cache directory for Task
* @returns Path to cache directory
*/
function getCacheDirectory() {
return external_path_namespaceObject.join(external_os_.tmpdir(), CACHE_DIR);
}
/**
* Get the directory path containing the Task executable.
* @param taskPath Path to Task installation
* @returns Directory containing the Task executable
*/
function getExecutableDirectoryPath(taskPath) {
return path.dirname(taskPath);
}
/**
* Copy a directory recursively with improved handling of deep directories.
* @param src Source directory
* @param dest Destination directory
* @throws Error if source directory does not exist
*/
async function copyDirRecursive(src, dest) {
// Validate source exists.
if (!fs.existsSync(src)) {
throw new Error(`Source directory does not exist: ${src}`);
}
const srcStats = fs.statSync(src);
if (srcStats.isFile()) {
// Create destination directory, if required.
const destDir = path.dirname(dest);
if (!fs.existsSync(destDir)) {
fs.mkdirSync(destDir, { recursive: true });
}
// For single file copy, use the file name if the destination is a directory.
const fileName = path.basename(src);
const destPath = fs.existsSync(dest) && fs.statSync(dest).isDirectory() ? path.join(dest, fileName) : dest;
// Copy with original permissions.
fs.copyFileSync(src, destPath);
fs.chmodSync(destPath, srcStats.mode);
return;
}
// Create destination directory, if required.
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest, { recursive: true });
}
// Use a queue-based approach to avoid stack overflow with deep directory structures.
const queue = [{ src, dest }];
// Process entries in breadth-first order.
while (queue.length > 0) {
const { src: currentSrc, dest: currentDest } = queue.shift();
// Read directory entries.
const entries = fs.readdirSync(currentSrc, { withFileTypes: true });
for (const entry of entries) {
const srcPath = path.join(currentSrc, entry.name);
const destPath = path.join(currentDest, entry.name);
if (entry.isDirectory()) {
// Create the destination directory.
if (!fs.existsSync(destPath)) {
fs.mkdirSync(destPath, { recursive: true });
}
// Add to queue instead of recursive call.
queue.push({ src: srcPath, dest: destPath });
}
else {
// Copy file directly and preserve permissions.
fs.copyFileSync(srcPath, destPath);
// Copy permissions from source.
const stats = fs.statSync(srcPath);
fs.chmodSync(destPath, stats.mode);
}
}
}
}
/**
* Extracts version from tag name by removing 'v' prefix if present
* @param tagName The tag name from GitHub release
Expand Down Expand Up @@ -48427,20 +48360,6 @@ async function fetchLatestRelease(githubToken) {
throw new Error(`Failed to fetch release information from ${RELEASES_API_URL}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
}
}
/**
* Parses a multiline input string into an array of strings
* @param input The multiline input string
* @returns Array of trimmed non-empty lines
*/
function parseMultilineInput(input) {
if (!input) {
return [];
}
return input
.split('\n')
.map((s) => s.trim())
.filter((s) => s !== '');
}
/**
* Validates and logs errors for requirements
* @param message Error message to display
Expand Down
81 changes: 0 additions & 81 deletions dist/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import * as core from '@actions/core';
import * as os from 'os';
import * as path from 'path';
import * as fs from 'fs';
import { RELEASES_API_URL, CACHE_DIR } from './constants';
/**
* Get the cache directory for Task
Expand All @@ -18,72 +17,6 @@ import { RELEASES_API_URL, CACHE_DIR } from './constants';
export function getCacheDirectory() {
return path.join(os.tmpdir(), CACHE_DIR);
}
/**
* Get the directory path containing the Task executable.
* @param taskPath Path to Task installation
* @returns Directory containing the Task executable
*/
export function getExecutableDirectoryPath(taskPath) {
return path.dirname(taskPath);
}
/**
* Copy a directory recursively with improved handling of deep directories.
* @param src Source directory
* @param dest Destination directory
* @throws Error if source directory does not exist
*/
export async function copyDirRecursive(src, dest) {
// Validate source exists.
if (!fs.existsSync(src)) {
throw new Error(`Source directory does not exist: ${src}`);
}
const srcStats = fs.statSync(src);
if (srcStats.isFile()) {
// Create destination directory, if required.
const destDir = path.dirname(dest);
if (!fs.existsSync(destDir)) {
fs.mkdirSync(destDir, { recursive: true });
}
// For single file copy, use the file name if the destination is a directory.
const fileName = path.basename(src);
const destPath = fs.existsSync(dest) && fs.statSync(dest).isDirectory() ? path.join(dest, fileName) : dest;
// Copy with original permissions.
fs.copyFileSync(src, destPath);
fs.chmodSync(destPath, srcStats.mode);
return;
}
// Create destination directory, if required.
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest, { recursive: true });
}
// Use a queue-based approach to avoid stack overflow with deep directory structures.
const queue = [{ src, dest }];
// Process entries in breadth-first order.
while (queue.length > 0) {
const { src: currentSrc, dest: currentDest } = queue.shift();
// Read directory entries.
const entries = fs.readdirSync(currentSrc, { withFileTypes: true });
for (const entry of entries) {
const srcPath = path.join(currentSrc, entry.name);
const destPath = path.join(currentDest, entry.name);
if (entry.isDirectory()) {
// Create the destination directory.
if (!fs.existsSync(destPath)) {
fs.mkdirSync(destPath, { recursive: true });
}
// Add to queue instead of recursive call.
queue.push({ src: srcPath, dest: destPath });
}
else {
// Copy file directly and preserve permissions.
fs.copyFileSync(srcPath, destPath);
// Copy permissions from source.
const stats = fs.statSync(srcPath);
fs.chmodSync(destPath, stats.mode);
}
}
}
}
/**
* Extracts version from tag name by removing 'v' prefix if present
* @param tagName The tag name from GitHub release
Expand Down Expand Up @@ -119,20 +52,6 @@ export async function fetchLatestRelease(githubToken) {
throw new Error(`Failed to fetch release information from ${RELEASES_API_URL}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
}
}
/**
* Parses a multiline input string into an array of strings
* @param input The multiline input string
* @returns Array of trimmed non-empty lines
*/
export function parseMultilineInput(input) {
if (!input) {
return [];
}
return input
.split('\n')
.map((s) => s.trim())
.filter((s) => s !== '');
}
/**
* Validates and logs errors for requirements
* @param message Error message to display
Expand Down
Loading