Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/tests-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- package.json
- yarn.lock
- jest.config.mjs
- jest/**
- packages/**
- tsconfig.*.json
pull_request:
Expand All @@ -19,6 +20,7 @@ on:
- package.json
- yarn.lock
- jest.config.mjs
- jest/**
- packages/**
- tsconfig.*.json
- admin/verdaccio.yaml
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- package.json
- yarn.lock
- jest.config.mjs
- jest/**
- packages/**
- tsconfig.*.json
- .github/workflows/tests-windows.yml
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- package.json
- yarn.lock
- jest.config.mjs
- jest/**
- packages/**
- tsconfig.*.json
- .github/workflows/tests.yml
Expand Down
32 changes: 0 additions & 32 deletions jest/snapshotPathNormalizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import os from 'os';
import path from 'path';
import fs from 'fs';
import _ from 'lodash';
import {escapePath} from '@docusaurus/utils';
import {version} from '@docusaurus/core/package.json';
Expand Down Expand Up @@ -65,48 +64,27 @@ function normalizePaths<T>(value: T): T {
}

const cwd = process.cwd();
const cwdReal = getRealPath(cwd);
const tempDir = os.tmpdir();
const tempDirReal = getRealPath(tempDir);
const homeDir = os.homedir();
const homeDirReal = getRealPath(homeDir);

const homeRelativeToTemp = path.relative(tempDir, homeDir);
const homeRelativeToTempReal = path.relative(tempDirReal, homeDir);
const homeRealRelativeToTempReal = path.relative(tempDirReal, homeDirReal);
const homeRealRelativeToTemp = path.relative(tempDir, homeDirReal);

const runner: ((val: string) => string)[] = [
(val) => (val.includes('keepAnsi') ? val : stripAnsi(val)),
// Replace process.cwd with <PROJECT_ROOT>
(val) => val.split(cwdReal).join('<PROJECT_ROOT>'),
(val) => val.split(cwd).join('<PROJECT_ROOT>'),

// Replace temp directory with <TEMP_DIR>
(val) => val.split(tempDirReal).join('<TEMP_DIR>'),
(val) => val.split(tempDir).join('<TEMP_DIR>'),

// Replace home directory with <HOME_DIR>
(val) => val.split(homeDirReal).join('<HOME_DIR>'),
(val) => val.split(homeDir).join('<HOME_DIR>'),

// Handle HOME_DIR nested inside TEMP_DIR
(val) =>
val
.split(`<TEMP_DIR>${path.sep + homeRelativeToTemp}`)
.join('<HOME_DIR>'),
(val) =>
val
.split(`<TEMP_DIR>${path.sep + homeRelativeToTempReal}`)
.join('<HOME_DIR>'),
(val) =>
val
.split(`<TEMP_DIR>${path.sep + homeRealRelativeToTempReal}`)
.join('<HOME_DIR>'),
(val) =>
val
.split(`<TEMP_DIR>${path.sep + homeRealRelativeToTemp}`)
.join('<HOME_DIR>'),

// Replace the Docusaurus version with a stub
(val) => val.split(version).join('<CURRENT_VERSION>'),
Expand Down Expand Up @@ -136,13 +114,3 @@ function normalizePaths<T>(value: T): T {
function shouldUpdate(value: unknown) {
return typeof value === 'string' && normalizePaths(value) !== value;
}

function getRealPath(pathname: string) {
try {
// eslint-disable-next-line no-restricted-properties
const realPath = fs.realpathSync(pathname);
return realPath;
} catch (err) {
return pathname;
}
}