Skip to content

Commit

Permalink
fix: expose getBinPath
Browse files Browse the repository at this point in the history
  • Loading branch information
agoldis committed Dec 12, 2022
1 parent 3782fb1 commit ac576e7
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Attach",
"port": 9229,
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
},
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/dist",
"preLaunchTask": "tsc: build - tsconfig.json",
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
]
}
]
}
10 changes: 10 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getCypressCLIBinPath } from './bin-path';
import { runInContext } from './context';
import * as lib from './patch';

Expand Down Expand Up @@ -36,3 +37,12 @@ export const inject = async (
new Map().set('cypressPackagePath', cypressPackagePath)
);
};

export const getBinPath = async (
cypressPackagePath: string = require.resolve('cypress')
) => {
return await runInContext(
getCypressCLIBinPath,
new Map().set('cypressPackagePath', cypressPackagePath)
);
};
2 changes: 2 additions & 0 deletions src/injected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { copyFileSync } from 'fs';
const Mod = require('module');
const req = Mod.prototype.require;

console.log('INJECTED');
// @ts-ignore
if (global.snapshotResult?.customRequire?.exports) {
// @ts-ignore
Expand All @@ -20,6 +21,7 @@ if (global.snapshotResult?.customRequire?.exports) {

Mod.prototype.require = function (...args) {
if (args[0].match(/app\.json/)) {
console.log('bingo! app.json');
return {
development: { api_url: 'http://localhost:1234/' },
test: { api_url: 'http://localhost:1234/' },
Expand Down

0 comments on commit ac576e7

Please sign in to comment.