Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass configuration via stdin #1263

Open
mficzel opened this issue Dec 9, 2020 · 2 comments
Open

Pass configuration via stdin #1263

mficzel opened this issue Dec 9, 2020 · 2 comments

Comments

@mficzel
Copy link

mficzel commented Dec 9, 2020

For integration into ci chains it would be great to be able to pass the configuration via stdin to the backstop command which would allow to create the configuration on the fly in non js environments.

I already tried to use /dev/stdin which theoretically could work via someCustomScript | backstop test --config=/dev/stdin but ran into the problems below.

BackstopJS v5.0.7
Loading config:  /dev/stdin 

/dev/fd/0:2
    "id": "Vendor_Site",
        ^

SyntaxError: Unexpected token ':'
    at wrapSafe (internal/modules/cjs/loader.js:1070:16)
    at Module._compile (internal/modules/cjs/loader.js:1120:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Module.require (internal/modules/cjs/loader.js:1042:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at loadProjectConfig (/Users/MFI/.nvm/versions/node/v12.16.2/lib/node_modules/backstopjs/core/util/makeConfig.js:46:20)
    at makeConfig (/Users/MFI/.nvm/versions/node/v12.16.2/lib/node_modules/backstopjs/core/util/makeConfig.js:62:38)
    at module.exports (/Users/MFI/.nvm/versions/node/v12.16.2/lib/node_modules/backstopjs/core/runner.js:5:16)

The same command works when used with temporary files someCustomScript > backstop.json && backstop test --config=backstop.json but it would be really good to avoid the temporary file.

@mficzel mficzel changed the title Pass config via stdin Pass configuration via stdin Dec 9, 2020
@garris
Copy link
Owner

garris commented Dec 9, 2020

Yup. You're not the first one to want this -- unfortunately the CLI really just wants a file. You could totally submit a PR to enhance that -- but it's a few hours of work. Instead -- it might just be easier to wrap the backstop module in a node script. Because you can totally pass in a string for the config at a module level. That is probably more like 30 mins of work max. There are node examples in the docs and you can check the /tests directory for a starter template.

Then you can pass literals from your command line to your node script which calls BackstopJS in the node world and passes the literal. Hope that helps.

If you decide to do it then please LMK. Would be great to add it to the project as an example or template.

@mficzel
Copy link
Author

mficzel commented Dec 9, 2020

Will look into it further. No clue wether i will achieve anything as my native language is php. Will take some time as integrating backstop into our ci is more like a long term project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants