Skip to main content

hash

v2.0.0

Use the moon hash command to inspect the contents and sources of a generated hash, also known as the hash manifest. This is extremely useful in debugging task inputs.

$ moon hash 0b55b234f1018581c45b00241d7340dc648c63e639fbafdaf85a4cd7e718fdde

# Query hash using short form
$ moon hash 0b55b234

By default, this will output the contents of the hash manifest (which is JSON), and the fully qualified resolved hash.

Hash: 0b55b234f1018581c45b00241d7340dc648c63e639fbafdaf85a4cd7e718fdde

{
"command": "build",
"args": ["./build"]
// ...
}

The command can also be output raw JSON by passing the --json flag.

Comparing hashes

The command can also be used to compare two hashes by diffing their contents. Simply pass two hashes as arguments.

# Diff between 2 hashes
$ moon hash 0b55b234f1018581c45b00241d7340dc648c63e639fbafdaf85a4cd7e718fdde 2388552fee5a02062d0ef402bdc7232f0a447458b058c80ce9c3d0d4d7cfe171

# Diff between 2 hashes using short form
$ moon hash 0b55b234 2388552f

By default, this will output the contents of a hash file (which is JSON), highlighting the differences between the left and right hashes. Lines that match will be printed in white, while the left differences printed in green, and right differences printed in red. If you use git diff, this will feel familiar to you.

Left:  0b55b234f1018581c45b00241d7340dc648c63e639fbafdaf85a4cd7e718fdde
Right: 2388552fee5a02062d0ef402bdc7232f0a447458b058c80ce9c3d0d4d7cfe171

{
"command": "build",
"args": [
+ "./dist"
- "./build"
],
...
}

The differences can also be output in JSON by passing the --json flag. The output has the following structure:

{
left: string,
left_hash: string,
left_diffs: string[],
right: string,
right_hash: string,
right_diffs: string[],
}

Options

  • --json - Display the diff in JSON format.

Configuration

  • hasher in .moon/workspace.yml