1
- const { describe, it } = require ( 'node:test' ) ;
2
- const path = require ( ' path') ;
3
- const assert = require ( ' assert') ;
4
- const resolveEnvironment = require ( '../src/resolveEnvironment' ) ;
1
+ import { describe , it } from 'node:test' ;
2
+ import path from 'node: path';
3
+ import assert from 'node: assert';
4
+ import resolveEnvironment from '../src/resolveEnvironment.js' ;
5
5
6
6
describe ( 'resolveEnvironment' , ( ) => {
7
7
it ( 'resolves the dev environment' , ( ) => {
@@ -117,7 +117,10 @@ describe('resolveEnvironment', () => {
117
117
it ( 'resolves the GitHub Actions environment' , ( ) => {
118
118
const githubEnv = {
119
119
GITHUB_SHA : 'ccddffddccffdd' ,
120
- GITHUB_EVENT_PATH : path . resolve ( __dirname , 'github_pull_request_event.json' ) ,
120
+ GITHUB_EVENT_PATH : path . resolve (
121
+ import . meta. dirname ,
122
+ 'github_pull_request_event.json' ,
123
+ ) ,
121
124
} ;
122
125
let result = resolveEnvironment ( githubEnv ) ;
123
126
assert . equal ( result . beforeSha , 'f95f852bd8fca8fcc58a9a2d6c842781e32a215e' ) ;
@@ -126,7 +129,10 @@ describe('resolveEnvironment', () => {
126
129
assert . equal ( result . message , 'Update the README with new information.' ) ;
127
130
128
131
// Try with a push event
129
- githubEnv . GITHUB_EVENT_PATH = path . resolve ( __dirname , 'github_push_event.json' ) ;
132
+ githubEnv . GITHUB_EVENT_PATH = path . resolve (
133
+ import . meta. dirname ,
134
+ 'github_push_event.json' ,
135
+ ) ;
130
136
result = resolveEnvironment ( githubEnv ) ;
131
137
assert . equal ( result . beforeSha , '6113728f27ae82c7b1a177c8d03f9e96e0adf246' ) ;
132
138
assert . equal ( result . afterSha , '0000000000000000000000000000000000000000' ) ;
@@ -138,7 +144,7 @@ describe('resolveEnvironment', () => {
138
144
139
145
// Try with a workflow_dispatch event
140
146
githubEnv . GITHUB_EVENT_PATH = path . resolve (
141
- __dirname ,
147
+ import . meta . dirname ,
142
148
'github_workflow_dispatch.json' ,
143
149
) ;
144
150
result = resolveEnvironment ( githubEnv ) ;
@@ -170,7 +176,10 @@ describe('resolveEnvironment', () => {
170
176
it ( 'resolves the GitHub merge group environment' , ( ) => {
171
177
const githubEnv = {
172
178
GITHUB_SHA : 'ccddffddccffdd' ,
173
- GITHUB_EVENT_PATH : path . resolve ( __dirname , 'github_merge_group_event.json' ) ,
179
+ GITHUB_EVENT_PATH : path . resolve (
180
+ import . meta. dirname ,
181
+ 'github_merge_group_event.json' ,
182
+ ) ,
174
183
} ;
175
184
let result = resolveEnvironment ( githubEnv ) ;
176
185
assert . equal ( result . beforeSha , 'f95f852bd8fca8fcc58a9a2d6c842781e32a215e' ) ;
0 commit comments