Skip to content

Commit

Permalink
make sandbox CLI params more tolerant
Browse files Browse the repository at this point in the history
  • Loading branch information
jkissel committed Nov 14, 2023
1 parent 9e2162d commit bad79b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- `labelSet` option for `CadenzaClient#showPage`

### Changed
- Made sandbox CLI more tolerant: The Cadenza URL can now also be passed with a '=' between `--cadenza-url` and the url.

## 1.4.0 - 2023-11-14
### Added
- Documentation for the development sandbox
Expand Down
8 changes: 7 additions & 1 deletion sandbox.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
const { execSync } = require('child_process');
const { URL } = require('url');

const CADENZA_URL_PARAM = '--cadenza-url';
const DEFAULT_CADENZA_URL = 'http://localhost:8080/cadenza';
const cadenzaUrl = new URL((process.argv[2] === '--cadenza-url' && process.argv[3]) || process.env.CADENZA_URL || DEFAULT_CADENZA_URL);

const index = process.argv.indexOf(CADENZA_URL_PARAM);
const cadenzaUrlFromArgs = index !== -1
? process.argv[index + 1]
: process.argv.find(arg => arg.startsWith(CADENZA_URL_PARAM + '='))?.slice(CADENZA_URL_PARAM.length + 1);
const cadenzaUrl = new URL(cadenzaUrlFromArgs || process.env.CADENZA_URL || DEFAULT_CADENZA_URL);

execSync(`npx --yes http-server -a localhost -c-1 -d false --proxy ${cadenzaUrl.origin} --proxy-options.headers.Origin ${cadenzaUrl.origin} -o /sandbox.html${cadenzaUrl.pathname !== '/' ? `?contextPath=${cadenzaUrl.pathname}` : ''}`, { stdio: 'inherit' });

0 comments on commit bad79b5

Please sign in to comment.