mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-13 02:30:09 -06:00
125 lines
4.1 KiB
Diff
125 lines
4.1 KiB
Diff
diff --git a/node_modules/bytenode/lib/cli.js b/node_modules/bytenode/lib/cli.js
|
|
index 9f57493..3ba173e 100755
|
|
--- a/node_modules/bytenode/lib/cli.js
|
|
+++ b/node_modules/bytenode/lib/cli.js
|
|
@@ -2,11 +2,15 @@
|
|
|
|
'use strict';
|
|
|
|
-const fs = require('fs');
|
|
-const path = require('path');
|
|
-const wrap = require('module').wrap;
|
|
-const spawnSync = require('child_process').spawnSync;
|
|
-const bytenode = require('./index.js');
|
|
+import fs from 'fs';
|
|
+import path from 'path';
|
|
+import * as mod from 'module';
|
|
+import { spawnSync } from 'child_process';
|
|
+import * as bytenode from './index.js';
|
|
+import * as url from 'url';
|
|
+
|
|
+const __filename = url.fileURLToPath(import.meta.url);
|
|
+const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
|
|
const args = process.argv.slice(2);
|
|
|
|
@@ -100,7 +104,7 @@ if (program.flags.includes('--compile')) {
|
|
if (program.flags.includes('--no-module')) {
|
|
process.stdout.write(bytenode.compileCode(script));
|
|
} else {
|
|
- process.stdout.write(bytenode.compileCode(wrap(script)));
|
|
+ process.stdout.write(bytenode.compileCode(mod.wrap(script)));
|
|
}
|
|
} catch (error) {
|
|
console.error(error);
|
|
@@ -136,13 +140,6 @@ if (program.flags.includes('--compile')) {
|
|
$ echo 'console.log("Hello");' | bytenode --compile - > hello.jsc
|
|
compile from stdin and save to \`hello.jsc\`
|
|
`);
|
|
-} else if (program.flags.includes('--version') && program.flags.length === 1 && program.files.length === 0) {
|
|
- const pkg = require('../package.json');
|
|
- console.log(pkg.name, pkg.version);
|
|
- console.log('Node', process.versions.node);
|
|
- if (process.versions.electron) {
|
|
- console.log('Electron', process.versions.electron);
|
|
- }
|
|
} else {
|
|
try {
|
|
spawnSync(program.nodeBin, [
|
|
diff --git a/node_modules/bytenode/lib/index.js b/node_modules/bytenode/lib/index.js
|
|
index cdd98cc..635bc27 100644
|
|
--- a/node_modules/bytenode/lib/index.js
|
|
+++ b/node_modules/bytenode/lib/index.js
|
|
@@ -1,11 +1,13 @@
|
|
'use strict';
|
|
|
|
-const fs = require('fs');
|
|
-const vm = require('vm');
|
|
-const v8 = require('v8');
|
|
-const path = require('path');
|
|
-const Module = require('module');
|
|
-const fork = require('child_process').fork;
|
|
+import fs from 'fs';
|
|
+import vm from 'vm';
|
|
+import v8 from 'v8';
|
|
+import path from 'path';
|
|
+import Module from 'module';
|
|
+import { fork } from 'child_process';
|
|
+import { createRequire } from 'module';
|
|
+import * as url from 'url';
|
|
|
|
v8.setFlagsFromString('--no-lazy');
|
|
|
|
@@ -46,10 +48,12 @@ const compileElectronCode = function (javascriptCode) {
|
|
return new Promise((resolve, reject) => {
|
|
let data = Buffer.from([]);
|
|
|
|
+ const require = createRequire(import.meta.url)
|
|
const electronPath = path.join(path.dirname(require.resolve('electron')), 'cli.js');
|
|
if (!fs.existsSync(electronPath)) {
|
|
throw new Error('Electron not installed');
|
|
}
|
|
+ const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
const bytenodePath = path.join(__dirname, 'cli.js');
|
|
|
|
// create a subprocess in which we run Electron as our Node and V8 engine
|
|
@@ -249,7 +253,7 @@ const runBytecodeFile = function (filename) {
|
|
return runBytecode(bytecodeBuffer);
|
|
};
|
|
|
|
-Module._extensions[COMPILED_EXTNAME] = function (fileModule, filename) {
|
|
+const runBytecodeAsModule = function (fileModule, filename) {
|
|
const bytecodeBuffer = fs.readFileSync(filename);
|
|
|
|
fixBytecode(bytecodeBuffer);
|
|
@@ -333,14 +337,13 @@ const loaderCode = function (targetPath) {
|
|
`;
|
|
};
|
|
|
|
-global.bytenode = {
|
|
+export {
|
|
compileCode,
|
|
compileFile,
|
|
compileElectronCode,
|
|
runBytecode,
|
|
runBytecodeFile,
|
|
addLoaderFile,
|
|
- loaderCode
|
|
+ loaderCode,
|
|
+ runBytecodeAsModule,
|
|
};
|
|
-
|
|
-module.exports = global.bytenode;
|
|
diff --git a/node_modules/bytenode/package.json b/node_modules/bytenode/package.json
|
|
index 6caff7c..72e2c46 100644
|
|
--- a/node_modules/bytenode/package.json
|
|
+++ b/node_modules/bytenode/package.json
|
|
@@ -3,6 +3,7 @@
|
|
"version": "1.3.7",
|
|
"description": "A minimalist bytecode compiler for Node.js",
|
|
"main": "lib/index.js",
|
|
+ "type": "module",
|
|
"bin": "lib/cli.js",
|
|
"types": "lib/index.d.ts",
|
|
"files": [
|