Add documentation for pack and publish

master
Mackiovello 7 years ago
parent 28d5bb5cab
commit 88fdbc5d39
  1. 32
      docs/pack-and-publish.md
  2. 10
      docs/pack.md
  3. 4
      docs/publish.md
  4. 2
      src/command/pack.rs
  5. 2
      src/command/publish.rs

@ -0,0 +1,32 @@
# pack and publish
The `publish` and `pack` commands interact with the pkg directory that's
created when you run `wasm-pack init`. The `pack` command creates a tarball
from the pkg directory and the `publish` command creates a tarball from the
pkg directory __and__ publishes it to the NPM registry.
Underneath, these commands use `npm pack` and `npm publish`. You can read
more about these in the NPM documentation:
- [`npm pack`](https://docs.npmjs.com/cli/pack)
- [`npm publish`](https://docs.npmjs.com/cli/publish)
Both these commands take the path to the pkg directory as the first argument.
You can either set the argument directly to the pkg directory or to the parent
of the pkg directory:
```
$ wasm-pack pack myproject/pkg
| 🎒 packed up your package!
$ wasm-pack pack myproject
| 🎒 packed up your package!
```
If you try to call `pack` or `publish` on another directory, you get an error:
```
$ wasm-pack pack myproject/src/
Unable to find the pkg directory at path 'myproject/src/', or in a child directory of 'myproject/src/'
```
If you don't set a path, they use the current directory as the path.

@ -1,10 +0,0 @@
# wasm-pack pack
The `wasm-pack pack` command is used to create a tarball of your wasm project
using the `npm pack` command. This is useful if you would like to create a
local tarball containing your package, without publishing it to the npm
registry.
You can read more about the `npm pack` command [here][npm-pack-documentation].
[npm-pack-documentation]: https://docs.npmjs.com/cli/pack

@ -1,4 +0,0 @@
# wasm-pack publish
The `wasm-pack publish` command will create a tarball of your wasm project,
and publish it to the npm registry.

@ -5,6 +5,8 @@ use slog::Logger;
use std::result;
use PBAR;
/// Executes the 'npm pack' command on the 'pkg' directory
/// which creates a tarball that can be published to the NPM registry
pub fn pack(path: Option<String>, log: &Logger) -> result::Result<(), Error> {
let crate_path = set_crate_path(path);

@ -5,6 +5,8 @@ use slog::Logger;
use std::result;
use PBAR;
/// Creates a tarball from a 'pkg' directory
/// and publishes it to the NPM registry
pub fn publish(path: Option<String>, log: &Logger) -> result::Result<(), Error> {
let crate_path = set_crate_path(path);

Loading…
Cancel
Save