Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@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 969,407 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.