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
6 changes: 3 additions & 3 deletions bin/stasis.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ assert(basename(jsname) === 'stasis' || pathsEqual(jsname, fileURLToPath(import.

function usage(prefix = '') {
console.error(`${prefix}\nUsage:
stasis run --lock=(add|replace|frozen|ignore) [--bundle=(add|replace|load|ignore)] [--bundle-file=path/to/bundle.br] [--full] [--mock] path/to/file.js ...
stasis run --lock=(add|replace|frozen|ignore) [--bundle=(add|replace|load|ignore)] [--bundle-file=path/to/bundle.br] [--dependencies] [--mock] path/to/file.js ...
stasis bundle [--mapping=path/to/remappings(.txt|.toml)] [--output=path/to/out.stasis.code.br] path/to/file.sol ...
stasis prune [path/to/project]
stasis audit path/to/file ...
Expand Down Expand Up @@ -50,15 +50,15 @@ if (command === '-v' || command === '--version') {
bundle: { type: 'string', default: 'none' },
'bundle-file': { type: 'string' },
debug: { type: 'boolean' },
full: { type: 'boolean' },
dependencies: { type: 'boolean' },
mock: { type: 'boolean' },
}

const { values } = parseArgs({ args: flags, options })
if (argv.length === 0) usage('Nothing to run: no path to file given')
if (!['none', 'ignore', 'add', 'replace', 'frozen'].includes(values.lock)) usage('Error: invalid --lock value')
const lock = values.lock
const scope = values.full ? 'full' : 'node_modules'
const scope = values.dependencies ? 'node_modules' : 'full'
const bundle = values.bundle
const bundleFile = values['bundle-file'] ? resolve(values['bundle-file']) : ''
const debug = values.debug ? '1' : ''
Expand Down
8 changes: 4 additions & 4 deletions tests/cli-mock.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ test('run --mock denies fs/child_process/network side-effects (fail closed) whil
rmSync(sentinel, { force: true })

const r = run(
['run', '--lock=none', '--full', '--bundle=add', `--bundle-file=${bundlePath}`, '--mock', 'src/entry.js'],
['run', '--lock=none', '--bundle=add', `--bundle-file=${bundlePath}`, '--mock', 'src/entry.js'],
{
cwd: tmp,
env: {
Expand Down Expand Up @@ -117,7 +117,7 @@ test('run --mock denies fs/child_process/network side-effects (fail closed) whil
}))

test('run --mock with --bundle=load is rejected (mock is for capture, not replay)', (t) => {
const r = run(['run', '--lock=frozen', '--full', '--bundle=load', '--bundle-file=/tmp/x.br', '--mock', 'a.js'])
const r = run(['run', '--lock=frozen', '--bundle=load', '--bundle-file=/tmp/x.br', '--mock', 'a.js'])
t.assert.equal(r.status, 1)
t.assert.match(r.stderr, /--mock is for capturing imports/)
})
Expand All @@ -127,7 +127,7 @@ test('run --mock refuses a --bundle-file whose ancestors do not exist', (t) => {
// would effectively disable --permission for the whole filesystem. Refuse
// instead and ask the user to pre-create a parent.
const r = run([
'run', '--lock=frozen', '--full', '--bundle=add',
'run', '--lock=frozen', '--bundle=add',
'--bundle-file=/zzz-no-such-toplevel-9999/foo.br', '--mock', 'a.js',
])
t.assert.equal(r.status, 1)
Expand All @@ -146,7 +146,7 @@ test('run --mock writes a --bundle-file under a not-yet-existing directory outsi
const sentinel = join(dirname(tmp), `mock-sentinel-${process.pid}.txt`)

const r = run(
['run', '--lock=none', '--full', '--bundle=add', `--bundle-file=${bundlePath}`, '--mock', 'src/entry.js'],
['run', '--lock=none', '--bundle=add', `--bundle-file=${bundlePath}`, '--mock', 'src/entry.js'],
{ cwd: tmp, env: { ...cleanEnv, STASIS_MOCK_SENTINEL: sentinel } }
)
try {
Expand Down
Loading