Skip to content

Commit

Permalink
Merge pull request #12 from joachimprinzbach/master
Browse files Browse the repository at this point in the history
Add ability to specify CYPRESS_MOON_BINARY in .npmrc
  • Loading branch information
vania-pooh authored Oct 12, 2021
2 parents 7231179 + f72fb98 commit d5e6d7d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ To override binary download URL:
$ CYPRESS_MOON_BINARY=https://company.example.com/download/cypress-moon npm install @aerokube/cypress-moon --save-dev
```

or use a .npmrc config with your own mirror:
`
CYPRESS_MOON_MIRROR=https://company.example.com/download/cypress-moon
`

To use binary already present on the file system:

```
Expand Down
14 changes: 10 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,23 @@ async function cypressMoon() {

const outputPath = path.join(dest, binName);
await fs.promises.mkdir(dest, {recursive: true});
const binaryUrlOverride = process.env.CYPRESS_MOON_BINARY;
const cypressMoonMirror = process.env.npm_config_CYPRESS_MOON_MIRROR;
const binaryUrlOverride = process.env.CYPRESS_MOON_BINARY
const binaryUrlIsLocalPath = await fileExists(binaryUrlOverride);
if (binaryUrlIsLocalPath) {
console.log(`Using local binary from ${binaryUrlOverride}...`);
await fs.promises.copyFile(binaryUrlOverride, outputPath);
}
const exists = await fileExists(outputPath);
if (!exists) {
const url = binaryUrlOverride ?
binaryUrlOverride :
`https://github.com/aerokube/moon/releases/download/${moonVersion}/${binName}`;
let url
if (cypressMoonMirror) {
url = `${cypressMoonMirror}/${moonVersion}/${binName}`
} else if (binaryUrlOverride) {
url = binaryUrlOverride
} else {
url = `https://github.com/aerokube/moon/releases/download/${moonVersion}/${binName}`;
}
console.log(`Downloading binary from ${url}...`);
await downloadFile(url, outputPath);
await fs.promises.chmod(outputPath, 0o755);
Expand Down

0 comments on commit d5e6d7d

Please sign in to comment.