Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@actions/io
Advanced tools
@actions/io is an npm package designed to provide file system operations for GitHub Actions. It allows you to perform tasks such as copying, moving, and removing files and directories within your GitHub Actions workflows.
Copy Files and Directories
This feature allows you to copy files and directories from one location to another. The code sample demonstrates copying a file from 'source/file.txt' to 'destination/file.txt'.
const io = require('@actions/io');
async function copyExample() {
try {
await io.cp('source/file.txt', 'destination/file.txt');
console.log('File copied successfully');
} catch (error) {
console.error('Error copying file:', error);
}
}
copyExample();
Move Files and Directories
This feature allows you to move files and directories from one location to another. The code sample demonstrates moving a file from 'source/file.txt' to 'destination/file.txt'.
const io = require('@actions/io');
async function moveExample() {
try {
await io.mv('source/file.txt', 'destination/file.txt');
console.log('File moved successfully');
} catch (error) {
console.error('Error moving file:', error);
}
}
moveExample();
Remove Files and Directories
This feature allows you to remove files and directories. The code sample demonstrates removing a file or directory at 'path/to/file_or_directory'.
const io = require('@actions/io');
async function removeExample() {
try {
await io.rmRF('path/to/file_or_directory');
console.log('File or directory removed successfully');
} catch (error) {
console.error('Error removing file or directory:', error);
}
}
removeExample();
Create Directories
This feature allows you to create directories, including any necessary parent directories. The code sample demonstrates creating a directory at 'path/to/new_directory'.
const io = require('@actions/io');
async function mkdirExample() {
try {
await io.mkdirP('path/to/new_directory');
console.log('Directory created successfully');
} catch (error) {
console.error('Error creating directory:', error);
}
}
mkdirExample();
fs-extra is a package that extends the native Node.js fs module with additional methods for file system operations. It provides similar functionalities to @actions/io, such as copying, moving, and removing files and directories, but it is more general-purpose and not specifically designed for GitHub Actions.
shelljs is a portable Unix shell commands for Node.js. It provides a wide range of file system operations, including copying, moving, and removing files and directories. It is more versatile and can be used in various environments, not just GitHub Actions.
node-fs is an extension to the built-in fs module, providing additional file system methods. It offers functionalities similar to @actions/io, such as creating directories and copying files, but it is less focused on GitHub Actions and more on general Node.js applications.
@actions/io
Core functions for cli filesystem scenarios
Recursively make a directory. Follows rules specified in man mkdir with the -p
option specified:
const io = require('@actions/io');
await io.mkdirP('path/to/make');
Copy or move files or folders. Follows rules specified in man cp and man mv:
const io = require('@actions/io');
// Recursive must be true for directories
const options = { recursive: true, force: false }
await io.cp('path/to/directory', 'path/to/dest', options);
await io.mv('path/to/file', 'path/to/dest');
Remove a file or folder recursively. Follows rules specified in man rm with the -r
and -f
rules specified.
const io = require('@actions/io');
await io.rmRF('path/to/directory');
await io.rmRF('path/to/file');
Get the path to a tool and resolves via paths. Follows the rules specified in man which.
const exec = require('@actions/exec');
const io = require('@actions/io');
const pythonPath: string = await io.which('python', true)
await exec.exec(`"${pythonPath}"`, ['main.py']);
FAQs
Actions io lib
The npm package @actions/io receives a total of 682,978 weekly downloads. As such, @actions/io popularity was classified as popular.
We found that @actions/io demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.