Skip to content

Commit

Permalink
Why does this fail on Windows?
Browse files Browse the repository at this point in the history
  • Loading branch information
badeball committed Sep 25, 2024
1 parent 01a227a commit af18ffa
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 258 deletions.
60 changes: 3 additions & 57 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,6 @@ concurrency:
cancel-in-progress: true

jobs:
prepare-versions:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
- id: set-matrix
name: Prepare
run: echo "matrix=$(node -p "JSON.stringify(require('./package.json').peerDependencies['cypress'].split(' || '))")" >> $GITHUB_OUTPUT
- run: npm -v

test:
needs: prepare-versions
runs-on: ubuntu-latest
container:
image: cypress/browsers:latest
strategy:
fail-fast: false
matrix:
cypress-version: ${{fromJson(needs.prepare-versions.outputs.matrix)}}
steps:
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Checkout
uses: actions/checkout@v4
- name: Cache NPM modules
uses: actions/cache@v4
with:
path: ~/.npm
key: npm-linux@${{ matrix.cypress-version }}
- name: Cache Cypress binaries
uses: actions/cache@v4
with:
path: ~/.cache/Cypress
key: cypress-linux@${{ matrix.cypress-version }}
- name: Change owner
run: "chown root: ."
- name: Dependencies
env:
CYPRESS_INSTALL_BINARY: "0"
run: |
npm install --engine-strict && \
npm install --no-save cypress@${{ matrix.cypress-version }} && \
env -u CYPRESS_INSTALL_BINARY npx cypress install
- name: Build
run: npm run build
- name: Test
run: npm run test
- name: Versions
run: |
npx cypress --version
node --version
npm --version
windows:
runs-on: windows-latest
env:
Expand Down Expand Up @@ -93,7 +37,9 @@ jobs:
- name: Remove Webpack test
run: rm features/loaders/webpack.feature
- name: Test
run: npm run test:integration
env:
DEBUG: cypress:electron,cypress-configuration,cypress-cucumber-preprocessor
run: npm run test:integration -- features\reporters\usage.feature:91
- name: Versions
run: |
npx cypress --version
Expand Down
118 changes: 0 additions & 118 deletions .github/workflows/examples-branch.yml

This file was deleted.

72 changes: 0 additions & 72 deletions .github/workflows/examples-master.yml

This file was deleted.

55 changes: 44 additions & 11 deletions lib/subpath-entrypoints/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ import { compile } from "../template";

import { assertAndReturn } from "../helpers/assertions";

import debug from "../helpers/debug";

const exists = (path: string) =>
fs.access(path).then(
() => true,
() => false,
);

export function createEsbuildPlugin(
configuration: Cypress.PluginConfigOptions,
options: { prettySourceMap: boolean } = { prettySourceMap: false },
Expand All @@ -31,24 +39,49 @@ export function createEsbuildPlugin(
(await fs.readFile(sourceMapLocation)).toString(),
);

/**
* In leu of https://github.com/evanw/esbuild/issues/2218.
*/
sourceMap.sources = sourceMap.sources.map((source: string) => {
return path.relative(
configuration.projectRoot,
path.normalize(path.join(path.dirname(outfile), source)),
);
});
const lastSource = sourceMap.sources[sourceMap.sources.length - 1];

const isRelativeToProjectRoot = (file: string) =>
exists(path.join(configuration.projectRoot, file));

const needPrettify =
lastSource != null && !(await isRelativeToProjectRoot(lastSource));

debug("last source", lastSource);
debug("project root", configuration.projectRoot);
debug(
"isRelativeToProjectRoot",
await isRelativeToProjectRoot(lastSource),
);

debug("sources before (all)", sourceMap.sources);
debug("sources before (last)", sourceMap.sources.slice(-5));

if (needPrettify) {
debug("esbuild: prettifying sources");

/**
* In leu of https://github.com/evanw/esbuild/issues/2218.
*/
sourceMap.sources = sourceMap.sources.map((source: string) => {
return path.relative(
configuration.projectRoot,
path.normalize(path.join(path.dirname(outfile), source)),
);
});
} else {
debug("esbuild: normal sources");
}

debug("sources after (all)", sourceMap.sources);
debug("sources after (last)", sourceMap.sources.slice(-5));

await fs.rm(sourceMapLocation);

const encoded = Buffer.from(JSON.stringify(sourceMap)).toString(
"base64",
);

console.log(encoded.length);

await fs.appendFile(
outfile,
`//# sourceMappingURL=data:application/json;base64,${encoded}\n`,
Expand Down

0 comments on commit af18ffa

Please sign in to comment.