Skip to content

Commit

Permalink
fix: no __dirname
Browse files Browse the repository at this point in the history
  • Loading branch information
SyMind committed May 21, 2024
1 parent 8a4dee8 commit fb618dc
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions tests/modernjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,35 @@ import { join } from 'node:path'
import { runInRepo, cd, $ } from '../utils'
import { RunOptions } from '../types'

const isGitHubActions = !!process.env.GITHUB_ACTIONS

function getCurrentCommitSha() {
return execSync('git rev-parse HEAD').toString().trim()
}

export async function test(options: RunOptions) {
const nxCachePath = join(__dirname, 'workspace/modernjs/modern.js')
let nxCacheKey = 'modernjs-nx-'
let nxCachePath: string
let nxCacheKey: string

await runInRepo({
...options,
repo: 'web-infra-dev/modern.js',
branch: process.env.MODERN_REF ?? 'main',
beforeInstall: async () => {
nxCacheKey += getCurrentCommitSha()
const restoreKeys = ['modernjs-nx-']
await cache.restoreCache([nxCachePath], nxCacheKey, restoreKeys)
if (isGitHubActions) {
nxCachePath = join(
process.cwd(),
'workspace/modernjs/modern.js/.nx/cache',
)
nxCacheKey = 'modernjs-nx-' + getCurrentCommitSha()
const restoreKeys = ['modernjs-nx-']
await cache.restoreCache([nxCachePath], nxCacheKey, restoreKeys)
}
},
afterInstall: async () => {
await cache.saveCache([nxCachePath], nxCacheKey)
if (isGitHubActions) {
await cache.saveCache([nxCachePath], nxCacheKey)
}
},
beforeTest: async () => {
cd('tests/e2e/builder')
Expand Down

0 comments on commit fb618dc

Please sign in to comment.