Registry / devops / cargo-cp-artifact

cargo-cp-artifact

JSON →
library0.1.9jsnpmunverified

Small CLI utility for copying Rust compiler artifacts (binaries, cdylibs, dylibs) produced by cargo to a specified output file. Current stable version 0.1.9, released as part of the Neon bindings ecosystem. Parses cargo's JSON metadata output (via --message-format=json) to reliably locate artifacts regardless of build profile or target. Differentiators: works with npm script integration via --npm flag, supports multiple artifact mappings, and wraps arbitrary commands as a child process. Not actively maintained; last release in 2023.

npm install cargo-cp-artifact
INSTALL
IMPORT
SIG · CARGO-CP-ARTIFACT
C
cargo-cp-artifact
devopsjavascriptv0.1.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cli tool
npm install -g cargo-cp-artifact
npm install cargo-cp-artifact (local install)
Typically installed globally or used via npx. No JavaScript API; pure CLI tool.
npx usage
npx cargo-cp-artifact -a cdylib my-crate lib/index.node -- cargo build --message-format=json-render-diagnostics
npx cargo-cp-artifact -a cdylib my-crate lib/index.node cargo build (missing -- separator)
The -- separator is required to distinguish cargo-cp-artifact args from wrapped command args.
npm script usage
"build": "cargo-cp-artifact -nc lib/index.node -- cargo build --message-format=json-render-diagnostics"
"build": "cargo-cp-artifact -a cdylib %npm_package_name% lib/index.node -- cargo build"
--npm flag reads npm_package_name env var automatically. Avoid manual env references.

Installs cargo-cp-artifact globally and uses it to copy a Rust cdylib to a .node file after building with cargo.

npm install -g cargo-cp-artifact # In a Rust project that produces a cdylib named 'my_crate' mkdir -p lib cargo-cp-artifact -a cdylib my_crate lib/index.node -- cargo build --release --message-format=json-render-diagnostics # Verify artifact was copied ls -la lib/index.node
cargo-cp-artifact --version
Debug
Known issues
gotchaThe -- separator is required between cargo-cp-artifact arguments and the wrapped command. Omitting it causes unexpected behavior.
fix
Use -- before the wrapped command, e.g., cargo-cp-artifact -a cdylib my-crate lib/index.node -- cargo build --message-format=json-render-diagnostics
affects: >=0.1.0
gotchaArtifact kind must match exactly: 'bin', 'cdylib', or 'dylib'. Alternatives like 'staticlib' will not be recognized.
fix
Use only 'bin', 'cdylib', or 'dylib' (or abbreviations 'b', 'c', 'd').
affects: >=0.1.0
gotchaThe crate name must match the Cargo.toml package name, not the directory name or the package name with hyphens. Hyphens in Cargo names are automatically converted to underscores in artifact names.
fix
Use the exact Cargo.toml [package] name. For npm integration, ensure npm_package_name matches or use --npm flag with proper env variable.
affects: >=0.1.0
Errors
Common errors & fixes
Error: No matching artifacts found for pattern
Crate name or artifact kind does not match any artifact emitted by cargo.
fix
Verify crate name in Cargo.toml and artifact kind (cdylib, bin, etc.). Use cargo build --release --message-format=json to see available artifacts.
Error: The argument '--artifact' requires 3 arguments but only 2 were provided
Missing the third argument (output file) for --artifact.
fix
Provide three values: artifact-kind crate-name output-file, e.g., --artifact cdylib my-crate lib/index.node
Error: unknown artifact kind 'staticlib'
Unsupported artifact kind specified.
fix
Use one of: bin, cdylib, dylib (or abbreviations b, c, d).
Upgrade
Version history
0.1.9latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
cargo-cp-artifact — npm install cargo-cp-artifact · libregistry