Support Nodejs.24 - Merge pull request #2110 from actions/salmanmkc/node24
Support Node.js 24
This commit is contained in:
commit
08306f6614
4 files changed
+39
-16
No files matched your search
+11
-11
@@ -643,8 +643,11 @@ describe('rmRF', () => {
|
|||||||
})
|
})
|
||||||
).toBe('test file content')
|
).toBe('test file content')
|
||||||
if (os.platform() === 'win32') {
|
if (os.platform() === 'win32') {
|
||||||
expect(await fs.readlink(symlinkLevel2Directory)).toBe(
|
// Node.js 24 changed behavior - fs.readlink no longer includes trailing backslash
|
||||||
`${symlinkDirectory}\\`
|
// Accept both formats for compatibility
|
||||||
|
const linkPath = await fs.readlink(symlinkLevel2Directory)
|
||||||
|
expect(linkPath.replace(/\\+$/, '')).toBe(
|
||||||
|
symlinkDirectory.replace(/\\+$/, '')
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
expect(await fs.readlink(symlinkLevel2Directory)).toBe(symlinkDirectory)
|
expect(await fs.readlink(symlinkLevel2Directory)).toBe(symlinkDirectory)
|
||||||
@@ -1201,9 +1204,8 @@ describe('which', () => {
|
|||||||
const originalPath = process.env['PATH']
|
const originalPath = process.env['PATH']
|
||||||
try {
|
try {
|
||||||
// modify PATH
|
// modify PATH
|
||||||
process.env[
|
process.env['PATH'] =
|
||||||
'PATH'
|
`${process.env['PATH']}${path.delimiter}${testPath}`
|
||||||
] = `${process.env['PATH']}${path.delimiter}${testPath}`
|
|
||||||
|
|
||||||
// find each file
|
// find each file
|
||||||
for (const fileName of Object.keys(files)) {
|
for (const fileName of Object.keys(files)) {
|
||||||
@@ -1274,9 +1276,8 @@ describe('which', () => {
|
|||||||
await fs.writeFile(notExpectedFilePath, '')
|
await fs.writeFile(notExpectedFilePath, '')
|
||||||
const originalPath = process.env['PATH']
|
const originalPath = process.env['PATH']
|
||||||
try {
|
try {
|
||||||
process.env[
|
process.env['PATH'] =
|
||||||
'PATH'
|
`${process.env['PATH']}${path.delimiter}${testPath}`
|
||||||
] = `${process.env['PATH']}${path.delimiter}${testPath}`
|
|
||||||
expect(await io.which(fileName)).toBe(expectedFilePath)
|
expect(await io.which(fileName)).toBe(expectedFilePath)
|
||||||
} finally {
|
} finally {
|
||||||
process.env['PATH'] = originalPath
|
process.env['PATH'] = originalPath
|
||||||
@@ -1438,9 +1439,8 @@ describe('findInPath', () => {
|
|||||||
try {
|
try {
|
||||||
// update the PATH
|
// update the PATH
|
||||||
for (const testPath of testPaths) {
|
for (const testPath of testPaths) {
|
||||||
process.env[
|
process.env['PATH'] =
|
||||||
'PATH'
|
`${process.env['PATH']}${path.delimiter}${testPath}`
|
||||||
] = `${process.env['PATH']}${path.delimiter}${testPath}`
|
|
||||||
}
|
}
|
||||||
// exact file names
|
// exact file names
|
||||||
expect(await io.findInPath(fileName)).toEqual(filePaths)
|
expect(await io.findInPath(fileName)).toEqual(filePaths)
|
||||||
|
|||||||
Generated
+3
-3
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@actions/io",
|
"name": "@actions/io",
|
||||||
"version": "1.1.3",
|
"version": "2.0.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@actions/io",
|
"name": "@actions/io",
|
||||||
"version": "1.1.3",
|
"version": "2.0.0",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@actions/io",
|
"name": "@actions/io",
|
||||||
"version": "1.1.3",
|
"version": "2.0.0",
|
||||||
"description": "Actions io lib",
|
"description": "Actions io lib",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"github",
|
"github",
|
||||||
|
|||||||
+24
-1
@@ -8,7 +8,6 @@ export const {
|
|||||||
mkdir,
|
mkdir,
|
||||||
open,
|
open,
|
||||||
readdir,
|
readdir,
|
||||||
readlink,
|
|
||||||
rename,
|
rename,
|
||||||
rm,
|
rm,
|
||||||
rmdir,
|
rmdir,
|
||||||
@@ -18,6 +17,30 @@ export const {
|
|||||||
} = fs.promises
|
} = fs.promises
|
||||||
// export const {open} = 'fs'
|
// export const {open} = 'fs'
|
||||||
export const 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
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
export async function readlink(fsPath: string): Promise<string> {
|
||||||
|
const result = await 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 (IS_WINDOWS && !result.endsWith('\\')) {
|
||||||
|
return `${result}\\`
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
// See https://github.com/nodejs/node/blob/d0153aee367422d0858105abec186da4dff0a0c5/deps/uv/include/uv/win.h#L691
|
// See https://github.com/nodejs/node/blob/d0153aee367422d0858105abec186da4dff0a0c5/deps/uv/include/uv/win.h#L691
|
||||||
export const UV_FS_O_EXLOCK = 0x10000000
|
export const UV_FS_O_EXLOCK = 0x10000000
|
||||||
export const READONLY = fs.constants.O_RDONLY
|
export const READONLY = fs.constants.O_RDONLY
|
||||||
|
|||||||
Reference in new issue
Block a user