Compare commits

...
10 Commits
Author SHA1 Message Date
Daniel Kennedy e83c2f495a Bump @actions/io to 3.0.2 2026-01-28 15:59:40 -05:00
Daniel Kennedy 8499e2aba9 @actions/exec: convert to ESM module 2026-01-28 15:59:40 -05:00
Salman Chishti 89ed8a4fe6 Merge pull request #2175 from actions/prepare-core-1.12.0-release
Prepare @actions/core 2.0.0 release
2025-12-08 16:28:47 +00:00
Salman Muin Kayser Chishti 99cb09b248 Timeout time back to normal, as it was like this for debugging 2025-12-08 12:47:19 +00:00
Salman Muin Kayser Chishti e356b02b96 fix: use detached:true on all platforms for exec stream tests
On Windows, detached:true is needed to properly keep stdio handles
open after the parent process exits.
2025-12-08 12:35:33 +00:00
Salman Muin Kayser Chishti 339756c0b9 fix: improve exec stream tests cross-platform handling
- Update spawn-wait-for-file.js to use proper stdio inheritance
- Add small delay before exit to ensure child process inherits handles
- Simplify test code to use the helper script instead of shell commands
2025-12-08 12:28:52 +00:00
Salman Muin Kayser Chishti 04237d9dc5 tests(exec): use platform-aware spawn options in spawn-wait-for-file script (detach on Unix, hide window on Windows) 2025-11-18 15:45:59 +00:00
Salman Muin Kayser Chishti c74c7fc4ed update hash files test 2025-11-18 14:21:47 +00:00
Salman Chishti 4d02b40881 Merge pull request #2176 from actions/prepare-exec-2.0.0-release
Prepare @actions/exec 2.0.0 release
2025-11-18 14:13:24 +00:00
Salman Muin Kayser Chishti cd39adf453 update package json 2025-11-04 13:53:28 +00:00
15 changed files with 112 additions and 95 deletions

No files matched your search

+11 -4
View File
@@ -1,13 +1,20 @@
# @actions/exec Releases # @actions/exec Releases
### 2.0.0 ## 3.0.0
- **Breaking change**: Package is now ESM-only
- CommonJS consumers must use dynamic `import()` instead of `require()`
## 2.0.0
- Add support for Node 24 [#2110](https://github.com/actions/toolkit/pull/2110) - Add support for Node 24 [#2110](https://github.com/actions/toolkit/pull/2110)
- Bump @actions/io dependency from ^1.0.1 to ^2.0.0 - Bump @actions/io dependency from ^1.0.1 to ^2.0.0
### 1.1.1 ## 1.1.1
- Update `lockfileVersion` to `v2` in `package-lock.json [#1024](https://github.com/actions/toolkit/pull/1024)
### 1.1.0 - Update `lockfileVersion` to `v2` in `package-lock.json` [#1024](https://github.com/actions/toolkit/pull/1024)
## 1.1.0
- [Fix stdline dropping large output](https://github.com/actions/toolkit/pull/773) - [Fix stdline dropping large output](https://github.com/actions/toolkit/pull/773)
- [Add getExecOutput function](https://github.com/actions/toolkit/pull/814) - [Add getExecOutput function](https://github.com/actions/toolkit/pull/814)
+36 -79
View File
@@ -1,5 +1,5 @@
import * as exec from '../src/exec' import * as exec from '../src/exec.js'
import * as im from '../src/interfaces' import * as im from '../src/interfaces.js'
import * as childProcess from 'child_process' import * as childProcess from 'child_process'
import * as fs from 'fs' import * as fs from 'fs'
@@ -11,6 +11,11 @@ import * as io from '@actions/io'
/* eslint-disable @typescript-eslint/unbound-method */ /* eslint-disable @typescript-eslint/unbound-method */
const IS_WINDOWS = process.platform === 'win32' const IS_WINDOWS = process.platform === 'win32'
const SPAWN_WAIT_SCRIPT = path.join(
__dirname,
'scripts',
'spawn-wait-for-file.cjs'
)
let outstream: stream.Writable let outstream: stream.Writable
let errstream: stream.Writable let errstream: stream.Writable
@@ -191,7 +196,7 @@ describe('@actions/exec', () => {
const scriptPath: string = path.join( const scriptPath: string = path.join(
__dirname, __dirname,
'scripts', 'scripts',
'stderroutput.js' 'stderroutput.cjs'
) )
const nodePath: string = await io.which('node', true) const nodePath: string = await io.which('node', true)
@@ -213,7 +218,7 @@ describe('@actions/exec', () => {
const scriptPath: string = path.join( const scriptPath: string = path.join(
__dirname, __dirname,
'scripts', 'scripts',
'stderroutput.js' 'stderroutput.cjs'
) )
const nodePath: string = await io.which('node', true) const nodePath: string = await io.which('node', true)
@@ -250,12 +255,12 @@ describe('@actions/exec', () => {
const stdErrPath: string = path.join( const stdErrPath: string = path.join(
__dirname, __dirname,
'scripts', 'scripts',
'stderroutput.js' 'stderroutput.cjs'
) )
const stdOutPath: string = path.join( const stdOutPath: string = path.join(
__dirname, __dirname,
'scripts', 'scripts',
'stdoutoutput.js' 'stdoutoutput.cjs'
) )
const nodePath: string = await io.which('node', true) const nodePath: string = await io.which('node', true)
let stdoutCalled = false let stdoutCalled = false
@@ -290,7 +295,7 @@ describe('@actions/exec', () => {
const stdlinePath: string = path.join( const stdlinePath: string = path.join(
__dirname, __dirname,
'scripts', 'scripts',
'stdlineoutput.js' 'stdlineoutput.cjs'
) )
const nodePath: string = await io.which('node', true) const nodePath: string = await io.which('node', true)
@@ -339,7 +344,7 @@ describe('@actions/exec', () => {
const waitForInput: string = path.join( const waitForInput: string = path.join(
__dirname, __dirname,
'scripts', 'scripts',
'wait-for-input.js' 'wait-for-input.cjs'
) )
const _testExecOptions = getExecOptions() const _testExecOptions = getExecOptions()
@@ -365,35 +370,20 @@ describe('@actions/exec', () => {
fs.writeFileSync(semaphorePath, '') fs.writeFileSync(semaphorePath, '')
const nodePath = await io.which('node', true) const nodePath = await io.which('node', true)
const scriptPath = path.join(__dirname, 'scripts', 'wait-for-file.js')
const debugList: string[] = [] const debugList: string[] = []
const _testExecOptions = getExecOptions() const _testExecOptions = getExecOptions()
_testExecOptions.delay = 500 _testExecOptions.delay = 500
_testExecOptions.windowsVerbatimArguments = true
_testExecOptions.listeners = { _testExecOptions.listeners = {
debug: (data: string) => { debug: (data: string) => {
debugList.push(data) debugList.push(data)
} }
} }
let exitCode: number const exitCode = await exec.exec(
if (IS_WINDOWS) { `"${nodePath}"`,
const toolName: string = await io.which('cmd.exe', true) [SPAWN_WAIT_SCRIPT, `file=${semaphorePath}`],
const args = [ _testExecOptions
'/D', // Disable execution of AutoRun commands from registry. )
'/E:ON', // Enable command extensions. Note, command extensions are enabled by default, unless disabled via registry.
'/V:OFF', // Disable delayed environment expansion. Note, delayed environment expansion is disabled by default, unless enabled via registry.
'/S', // Will cause first and last quote after /C to be stripped.
'/C',
`"start "" /B "${nodePath}" "${scriptPath}" "file=${semaphorePath}""`
]
exitCode = await exec.exec(`"${toolName}"`, args, _testExecOptions)
} else {
const toolName: string = await io.which('bash', true)
const args = ['-c', `node '${scriptPath}' 'file=${semaphorePath}' &`]
exitCode = await exec.exec(`"${toolName}"`, args, _testExecOptions)
}
expect(exitCode).toBe(0) expect(exitCode).toBe(0)
expect( expect(
@@ -411,36 +401,21 @@ describe('@actions/exec', () => {
fs.writeFileSync(semaphorePath, '') fs.writeFileSync(semaphorePath, '')
const nodePath = await io.which('node', true) const nodePath = await io.which('node', true)
const scriptPath = path.join(__dirname, 'scripts', 'wait-for-file.js')
const debugList: string[] = [] const debugList: string[] = []
const _testExecOptions = getExecOptions() const _testExecOptions = getExecOptions()
_testExecOptions.delay = 500 _testExecOptions.delay = 500
_testExecOptions.windowsVerbatimArguments = true
_testExecOptions.listeners = { _testExecOptions.listeners = {
debug: (data: string) => { debug: (data: string) => {
debugList.push(data) debugList.push(data)
} }
} }
let toolName: string
let args: string[]
if (IS_WINDOWS) {
toolName = await io.which('cmd.exe', true)
args = [
'/D', // Disable execution of AutoRun commands from registry.
'/E:ON', // Enable command extensions. Note, command extensions are enabled by default, unless disabled via registry.
'/V:OFF', // Disable delayed environment expansion. Note, delayed environment expansion is disabled by default, unless enabled via registry.
'/S', // Will cause first and last quote after /C to be stripped.
'/C',
`"start "" /B "${nodePath}" "${scriptPath}" "file=${semaphorePath}"" & exit /b 123`
]
} else {
toolName = await io.which('bash', true)
args = ['-c', `node '${scriptPath}' 'file=${semaphorePath}' & exit 123`]
}
await exec await exec
.exec(`"${toolName}"`, args, _testExecOptions) .exec(
`"${nodePath}"`,
[SPAWN_WAIT_SCRIPT, `file=${semaphorePath}`, 'exitCode=123'],
_testExecOptions
)
.then(() => { .then(() => {
throw new Error('Should not have succeeded') throw new Error('Should not have succeeded')
}) })
@@ -465,40 +440,22 @@ describe('@actions/exec', () => {
fs.writeFileSync(semaphorePath, '') fs.writeFileSync(semaphorePath, '')
const nodePath = await io.which('node', true) const nodePath = await io.which('node', true)
const scriptPath = path.join(__dirname, 'scripts', 'wait-for-file.js')
const debugList: string[] = [] const debugList: string[] = []
const _testExecOptions = getExecOptions() const _testExecOptions = getExecOptions()
_testExecOptions.delay = 500 _testExecOptions.delay = 500
_testExecOptions.failOnStdErr = true _testExecOptions.failOnStdErr = true
_testExecOptions.windowsVerbatimArguments = true
_testExecOptions.listeners = { _testExecOptions.listeners = {
debug: (data: string) => { debug: (data: string) => {
debugList.push(data) debugList.push(data)
} }
} }
let toolName: string
let args: string[]
if (IS_WINDOWS) {
toolName = await io.which('cmd.exe', true)
args = [
'/D', // Disable execution of AutoRun commands from registry.
'/E:ON', // Enable command extensions. Note, command extensions are enabled by default, unless disabled via registry.
'/V:OFF', // Disable delayed environment expansion. Note, delayed environment expansion is disabled by default, unless enabled via registry.
'/S', // Will cause first and last quote after /C to be stripped.
'/C',
`"start "" /B "${nodePath}" "${scriptPath}" "file=${semaphorePath}"" & echo hi 1>&2`
]
} else {
toolName = await io.which('bash', true)
args = [
'-c',
`node '${scriptPath}' 'file=${semaphorePath}' & echo hi 1>&2`
]
}
await exec await exec
.exec(`"${toolName}"`, args, _testExecOptions) .exec(
`"${nodePath}"`,
[SPAWN_WAIT_SCRIPT, `file=${semaphorePath}`, 'stderr=true'],
_testExecOptions
)
.then(() => { .then(() => {
throw new Error('Should not have succeeded') throw new Error('Should not have succeeded')
}) })
@@ -515,7 +472,7 @@ describe('@actions/exec', () => {
).toBe(1) ).toBe(1)
fs.unlinkSync(semaphorePath) fs.unlinkSync(semaphorePath)
}) }, 10000)
it('Exec roots relative tool path using unrooted options.cwd', async () => { it('Exec roots relative tool path using unrooted options.cwd', async () => {
let exitCode: number let exitCode: number
@@ -665,12 +622,12 @@ describe('@actions/exec', () => {
const stdErrPath: string = path.join( const stdErrPath: string = path.join(
__dirname, __dirname,
'scripts', 'scripts',
'stderroutput.js' 'stderroutput.cjs'
) )
const stdOutPath: string = path.join( const stdOutPath: string = path.join(
__dirname, __dirname,
'scripts', 'scripts',
'stdoutoutput.js' 'stdoutoutput.cjs'
) )
const nodePath: string = await io.which('node', true) const nodePath: string = await io.which('node', true)
@@ -696,12 +653,12 @@ describe('@actions/exec', () => {
const stdErrPath: string = path.join( const stdErrPath: string = path.join(
__dirname, __dirname,
'scripts', 'scripts',
'stderroutput.js' 'stderroutput.cjs'
) )
const stdOutPath: string = path.join( const stdOutPath: string = path.join(
__dirname, __dirname,
'scripts', 'scripts',
'stdoutoutput.js' 'stdoutoutput.cjs'
) )
const nodePath: string = await io.which('node', true) const nodePath: string = await io.which('node', true)
@@ -746,12 +703,12 @@ describe('@actions/exec', () => {
const stdErrPath: string = path.join( const stdErrPath: string = path.join(
__dirname, __dirname,
'scripts', 'scripts',
'stderroutput.js' 'stderroutput.cjs'
) )
const stdOutPath: string = path.join( const stdOutPath: string = path.join(
__dirname, __dirname,
'scripts', 'scripts',
'stdoutoutputlarge.js' 'stdoutoutputlarge.cjs'
) )
const nodePath: string = await io.which('node', true) const nodePath: string = await io.which('node', true)
@@ -796,7 +753,7 @@ describe('@actions/exec', () => {
const stdOutPath: string = path.join( const stdOutPath: string = path.join(
__dirname, __dirname,
'scripts', 'scripts',
'stdoutputspecial.js' 'stdoutputspecial.cjs'
) )
const nodePath: string = await io.which('node', true) const nodePath: string = await io.which('node', true)
+44
View File
@@ -0,0 +1,44 @@
const childProcess = require('child_process')
const path = require('path')
// Parse args
const args = {}
for (const arg of process.argv.slice(2)) {
const idx = arg.indexOf('=')
if (idx !== -1) {
args[arg.slice(0, idx)] = arg.slice(idx + 1)
}
}
const filePath = args.file
if (!filePath) {
throw new Error('file is not specified')
}
// Spawn wait-for-file.cjs with inherited stdio
// This creates a grandchild process that holds the stdio handles open
// after this process (the child) exits
const waitScript = path.join(__dirname, 'wait-for-file.cjs')
const isWindows = process.platform === 'win32'
// On Windows, use detached:true to properly keep streams open
// On Unix, detached:true also works and creates a new process group
const child = childProcess.spawn(process.execPath, [waitScript, `file=${filePath}`], {
stdio: ['ignore', 'inherit', 'inherit'],
detached: true,
windowsHide: true
})
// Don't wait for child to exit
child.unref()
// Handle optional stderr output (must happen BEFORE we exit)
if (args.stderr === 'true') {
process.stderr.write('hi')
}
// Small delay to ensure child has started and inherited handles
setTimeout(() => {
const exitCode = args.exitCode ? parseInt(args.exitCode, 10) : 0
process.exit(exitCode)
}, 50)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+6 -6
View File
@@ -1,21 +1,21 @@
{ {
"name": "@actions/exec", "name": "@actions/exec",
"version": "1.1.1", "version": "3.0.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@actions/exec", "name": "@actions/exec",
"version": "1.1.1", "version": "3.0.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/io": "^1.0.1" "@actions/io": "^3.0.2"
} }
}, },
"node_modules/@actions/io": { "node_modules/@actions/io": {
"version": "1.1.3", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.3.tgz", "resolved": "https://registry.npmjs.org/@actions/io/-/io-3.0.2.tgz",
"integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==", "integrity": "sha512-nRBchcMM+QK1pdjO7/idu86rbJI5YHUKCvKs0KxnSYbVe3F51UfGxuZX4Qy/fWlp6l7gWFwIkrOzN+oUK03kfw==",
"license": "MIT" "license": "MIT"
} }
} }
+9 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "@actions/exec", "name": "@actions/exec",
"version": "2.0.0", "version": "3.0.0",
"description": "Actions exec lib", "description": "Actions exec lib",
"keywords": [ "keywords": [
"github", "github",
@@ -9,8 +9,15 @@
], ],
"homepage": "https://github.com/actions/toolkit/tree/main/packages/exec", "homepage": "https://github.com/actions/toolkit/tree/main/packages/exec",
"license": "MIT", "license": "MIT",
"type": "module",
"main": "lib/exec.js", "main": "lib/exec.js",
"types": "lib/exec.d.ts", "types": "lib/exec.d.ts",
"exports": {
".": {
"types": "./lib/exec.d.ts",
"import": "./lib/exec.js"
}
},
"directories": { "directories": {
"lib": "lib", "lib": "lib",
"test": "__tests__" "test": "__tests__"
@@ -36,6 +43,6 @@
"url": "https://github.com/actions/toolkit/issues" "url": "https://github.com/actions/toolkit/issues"
}, },
"dependencies": { "dependencies": {
"@actions/io": "^2.0.0" "@actions/io": "^3.0.2"
} }
} }
+2 -2
View File
@@ -1,6 +1,6 @@
import {StringDecoder} from 'string_decoder' import {StringDecoder} from 'string_decoder'
import {ExecOptions, ExecOutput, ExecListeners} from './interfaces' import {ExecOptions, ExecOutput, ExecListeners} from './interfaces.js'
import * as tr from './toolrunner' import * as tr from './toolrunner.js'
export {ExecOptions, ExecOutput, ExecListeners} export {ExecOptions, ExecOutput, ExecListeners}
+1 -1
View File
@@ -3,7 +3,7 @@ import * as events from 'events'
import * as child from 'child_process' import * as child from 'child_process'
import * as path from 'path' import * as path from 'path'
import * as stream from 'stream' import * as stream from 'stream'
import * as im from './interfaces' import * as im from './interfaces.js'
import * as io from '@actions/io' import * as io from '@actions/io'
import * as ioUtil from '@actions/io/lib/io-util' import * as ioUtil from '@actions/io/lib/io-util'
import {setTimeout} from 'timers' import {setTimeout} from 'timers'
+3 -1
View File
@@ -3,7 +3,9 @@
"compilerOptions": { "compilerOptions": {
"baseUrl": "./", "baseUrl": "./",
"outDir": "./lib", "outDir": "./lib",
"rootDir": "./src" "rootDir": "./src",
"module": "node16",
"moduleResolution": "node16"
}, },
"include": [ "include": [
"./src" "./src"