grafana / xk6-exec

A k6 extension for running external commands.
Apache License 2.0
20 stars 21 forks source link

Module name collides with k6/execution #10

Closed sarasensible closed 1 year ago

sarasensible commented 1 year ago

The name of this module collides with exec from k6/execution.

Attempted workaround (does not work)

import exec from 'k6/execution';
import { exec as execer } from 'k6/x/exec';
console.log(execer.command("pwd"))

Results in

TypeError: Cannot read property 'command' of undefined or null
mstoykov commented 1 year ago

Hi @sarasensible,

There is no collision - both export are a default ones and you can do a default import and when doing that you can name them w/e.

import exec from 'k6/execution'andimport something from 'k6/execution'will just bind the same thing toexecorsomething`. In both cases the module has no way of knowing or caring how the default export it provided is imported.

So in your case you can do import execer from 'k6/x/exec' or if you want you can also do import { default as execer } from 'k6/x/exec'.

If you only need the command import { command } from 'k6/x/exec' and then use it directly as command instead of execer.command.

I will be closing this issue, but if you have more question you might try the community forum

sarasensible commented 1 year ago

Yes both options you gave work for me. Thanks!