Skip to content

Commit

Permalink
support download on install
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed Apr 20, 2023
1 parent bea938d commit d6572fc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ npm i -g runme
runme list
```

By default this package downloads the [Runme CLI](https://github.com/stateful/runme) when the interface is used for the first time. You can download it after running `npm install` by setting the `RUNME_DOWNLOAD_ON_INSTALL` environment flag. You can also modify the Runme version that is being installed by setting `RUNME_VERSION`, e.g.:

```sh
RUNME_DOWNLOAD_ON_INSTALL=1 RUNME_VERSION=1.0.0 npm install runme
npx runme --version
```

## Usage

The module exposes the following methods:
Expand Down
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"clean": "rimraf dist",
"compile": "tsc -p ./tsconfig.json",
"copy": "cp src/cjs/package.json dist/cjs/package.json",
"postinstall": "node ./postInstall.js",
"release": "release-it --github.release --ci --npm.skipChecks --no-git.requireCleanWorkingDir",
"test": "run-s test:*",
"test:nodejs": "vitest --config ./vitest.config.ts",
Expand Down
9 changes: 9 additions & 0 deletions postInstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import fs from 'node:fs/promises'

const isCompiled = await fs.access('./dist').then(() => true, () => false)
if (isCompiled && process.env.RUNME_DOWNLOAD_ON_INSTALL) {
const { download } = await import('./dist/installer.js')
const version = process.env.RUNME_VERSION || 'latest'
console.log(`Download Runme ${version}`)
await download(version)
}

0 comments on commit d6572fc

Please sign in to comment.