Skip to content

Commit

Permalink
fix: Remove dregs of node -r esm
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed Aug 17, 2021
1 parent df06782 commit e5bf91e
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 25 deletions.
4 changes: 2 additions & 2 deletions packages/SwingSet/docs/how-to-replay.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ By modifying the replay tool, you can control how the replay is performed:
Suppose you have an agoric chain node (validator or non-voting fullnode) that keeps its state in `~/.ag-chain-cosmos/`. After stopping the node (so the database is not being modified during read), the following invocation will extract a list of vatIDs to choose from:

```
$ node -r esm extract-transcript-from-kerneldb.js ~/.ag-chain-cosmos/data/ag-cosmos-chain-state
$ node extract-transcript-from-kerneldb.js ~/.ag-chain-cosmos/data/ag-cosmos-chain-state
all vats:
v1 : bank (26464 deliveries)
Expand Down Expand Up @@ -55,7 +55,7 @@ v24 : (dynamic) {"managerType":"xs-worker"} (1 deliveries)
To replay the "zoe" vat, first extract the transcript:

```
$ node -r esm extract-transcript-from-kerneldb.js ~/.ag-chain-cosmos/data/ag-cosmos-chain-state zoe
$ node extract-transcript-from-kerneldb.js ~/.ag-chain-cosmos/data/ag-cosmos-chain-state zoe
extracting transcript for vat v11 into transcript-v11.sst
29905 transcript entries
Expand Down
4 changes: 1 addition & 3 deletions packages/SwingSet/src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,6 @@ export async function makeSwingsetController(

// this launches a worker in a Node.js thread (aka "Worker")
function makeNodeWorker() {
// TODO: after we move away from `-r esm` and use real ES6 modules, point
// this at nodeWorkerSupervisor.js instead of the CJS intermediate
const supercode = new URL(
'kernel/vatManager/supervisor-nodeworker.js',
import.meta.url,
Expand All @@ -242,7 +240,7 @@ export async function makeSwingsetController(
'kernel/vatManager/supervisor-subprocess-node.js',
import.meta.url,
).pathname;
const args = ['-r', 'esm', supercode];
const args = [supercode];
return startSubprocessWorker(process.execPath, args);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/tools/db-delete.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S node -r esm
#!/usr/bin/env node

import '@agoric/install-ses';
import process from 'process';
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/tools/db-get.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S node -r esm
#!/usr/bin/env node

import '@agoric/install-ses';
import process from 'process';
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/tools/db-set.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S node -r esm
#!/usr/bin/env node

import '@agoric/install-ses';
import process from 'process';
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/tools/replace-bundle.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S node -r esm
#!/usr/bin/env node

import '@agoric/install-ses';
import process from 'process';
Expand Down
8 changes: 4 additions & 4 deletions packages/eventual-send/integration-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"main": "index.js",
"private": true,
"scripts": {
"test": "tape -r esm test/*.js",
"test": "tape test/*.js",
"create-test-file-no-lib-cjs": "rollup -c transform-tests/config/rollup.config.no-lib.js",
"test:pre-release": "tape -r esm test/test-pre-release.js",
"test:post-release": "tape -r esm test/test-post-release.js",
"test:pre-release": "tape test/test-pre-release.js",
"test:post-release": "tape test/test-post-release.js",
"create-test-file-esm": "rollup -c transform-tests/config/rollup.config.esm.js",
"create-test-file-cjs": "rollup -c transform-tests/config/rollup.config.cjs.js",
"create-test-file-browserified-tape": "browserify transform-tests/output/test.no-lib.cjs.js > transform-tests/output/test.tape-no-lib.js --exclude @agoric/eventual-send",
"build:webpack": "webpack -r esm --display-error-details --config pre-release-browser-tests/webpack/webpack.config.js",
"build:webpack": "webpack --display-error-details --config pre-release-browser-tests/webpack/webpack.config.js",
"build:browserify": "browserify transform-tests/output/test.cjs.js > bundles/browserify.js",
"build:rollup": "rollup -c pre-release-browser-tests/rollup/rollup.config.test.js",
"build:parcel": "parcel build pre-release-browser-tests/parcel/index.html --public-url ./ -d bundles/parcel"
Expand Down
21 changes: 10 additions & 11 deletions packages/xsnap/src/replay.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Replay usage:
* node -r esm replay.js <folder>...
* node replay.js <folder>...
*
* In case of more than one folder:
* 1. Spawn based on 00000-options.json in the first folder
Expand All @@ -10,6 +10,9 @@
*/
// @ts-check

import childProcessPowers from 'child_process';
import osPowers from 'os';
import fsPowers from 'fs';
import { xsnap, DEFAULT_CRANK_METERING_LIMIT } from './xsnap.js';
import { queue } from './stream.js';

Expand Down Expand Up @@ -293,17 +296,13 @@ export async function main(argv, { spawn, osType, readdirSync, readFileSync }) {
await replayXSnap(options, folders, { readdirSync, readFileSync });
}

/* global require, module, process, require */
if (typeof require !== 'undefined' && require.main === module) {
/* global process */
if (process.argv[1] === new URL(import.meta.url).pathname) {
main([...process.argv.slice(2)], {
// eslint-disable-next-line global-require
spawn: require('child_process').spawn,
// eslint-disable-next-line global-require
osType: require('os').type,
// eslint-disable-next-line global-require
readdirSync: require('fs').readdirSync,
// eslint-disable-next-line global-require
readFileSync: require('fs').readFileSync,
spawn: childProcessPowers.spawn,
osType: osPowers.type,
readdirSync: fsPowers.readdirSync,
readFileSync: fsPowers.readFileSync,
}).catch(err => {
console.error(err);
process.exit(err.code || 1);
Expand Down
2 changes: 1 addition & 1 deletion packages/xsnap/src/xsrepl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
real0=$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")
thisdir=$(cd "$(dirname -- "$real0")" > /dev/null && pwd -P)
node -r esm "$thisdir/xsrepl.js" "$*"
node "$thisdir/xsrepl.js" "$*"

0 comments on commit e5bf91e

Please sign in to comment.