|
|
|
@ -1,7 +1,8 @@ |
|
|
|
|
use command::utils::set_crate_path; |
|
|
|
|
use command::utils::{find_pkg_directory, set_crate_path}; |
|
|
|
|
use error::Error; |
|
|
|
|
use npm; |
|
|
|
|
use slog::Logger; |
|
|
|
|
use std::path::Path; |
|
|
|
|
use std::result; |
|
|
|
|
use PBAR; |
|
|
|
|
|
|
|
|
@ -9,14 +10,13 @@ pub fn pack(path: Option<String>, log: &Logger) -> result::Result<(), Error> { |
|
|
|
|
let crate_path = set_crate_path(path); |
|
|
|
|
|
|
|
|
|
info!(&log, "Packing up the npm package..."); |
|
|
|
|
npm::npm_pack(&crate_path).map_err(|e| { |
|
|
|
|
match e { |
|
|
|
|
Error::Io { .. } => Error::PkgNotFound { |
|
|
|
|
message: format!("Unable to find the pkg directory at path '{}', set the path as the parent directory of the pkg directory", &crate_path), |
|
|
|
|
}, |
|
|
|
|
e => e, |
|
|
|
|
} |
|
|
|
|
let pkg_directory: Box<&Path> = find_pkg_directory(&crate_path).ok_or(Error::PkgNotFound { |
|
|
|
|
message: format!( |
|
|
|
|
"Unable to find the pkg directory at path '{}', or in a child directory of '{}'", |
|
|
|
|
&crate_path, &crate_path |
|
|
|
|
), |
|
|
|
|
})?; |
|
|
|
|
npm::npm_pack(&pkg_directory.to_string_lossy())?; |
|
|
|
|
#[cfg(not(target_os = "windows"))] |
|
|
|
|
info!(&log, "Your package is located at {}/pkg", &crate_path); |
|
|
|
|
#[cfg(target_os = "windows")] |
|
|
|
|