diff --git a/README.md b/README.md index c920466..6a76896 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,9 @@ + + decryption on npm +

Dependency-light building blocks for mnemonics, envelope encryption, Shamir secret sharing and team @@ -21,6 +24,16 @@ Constructive endpoint you name. The primitives have been audited upstream; the formats and tools built on them here have not. See [Audit status](#audit-status) for exactly where that line is. +## Install + +```bash +npm install -g decryption +dcrypt --help +``` + +That installs the `dcrypt` command. To try it without installing, run `npx decryption --help`. For the +libraries, install the scoped packages below, e.g. `npm install @decryption/core`. + ## Packages | Package | npm | Source | Description | diff --git a/packages/cli/__tests__/main.test.ts b/packages/cli/__tests__/main.test.ts index 8db956c..451ddd6 100644 --- a/packages/cli/__tests__/main.test.ts +++ b/packages/cli/__tests__/main.test.ts @@ -12,6 +12,7 @@ describe('main', () => { it('is what the decryption package runs', () => { const wrapper = readFileSync(join(__dirname, '../../decryption/index.js'), 'utf8'); - expect(wrapper).toContain("require('@decryption/cli').main()"); + expect(wrapper).toContain("require('@decryption/cli')"); + expect(wrapper).toContain('cli.main()'); }); }); diff --git a/packages/decryption/index.js b/packages/decryption/index.js index 4d5e907..e310a9c 100755 --- a/packages/decryption/index.js +++ b/packages/decryption/index.js @@ -1,4 +1,11 @@ #!/usr/bin/env node -// `npm install -g decryption` installs the `dcrypt` command from @decryption/cli. -// This package holds no code of its own; it runs the CLI at the exact version it depends on. -require('@decryption/cli').main(); +// `decryption` is the entry point: `npm install -g decryption` installs the `dcrypt` command, and +// `require('decryption')` gives you the @decryption/cli API. This package holds no code of its own; +// it runs the CLI at the exact version it depends on. +const cli = require('@decryption/cli'); + +if (require.main === module) { + cli.main(); +} else { + module.exports = cli; +}