Skip to content

Commit

Permalink
Include project path in toolchain key warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskrycho committed May 15, 2019
1 parent 95ab2c5 commit 3635705
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion crates/volta-core/src/manifest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Manifest {
file: package_file.to_string_lossy().to_string(),
}
})?;
serial.into_manifest()
serial.into_manifest(&package_file)
}

/// Returns a reference to the platform image specified by manifest, if any.
Expand Down
22 changes: 16 additions & 6 deletions crates/volta-core/src/manifest/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::fmt;
use std::hash::Hash;
use std::marker::PhantomData;
use std::ops::{Deref, DerefMut};
use std::path::Path;
use std::rc::Rc;

use serde;
Expand Down Expand Up @@ -109,7 +110,7 @@ impl Engines {
}

impl Manifest {
pub fn into_manifest(self) -> Fallible<manifest::Manifest> {
pub fn into_manifest(self, package_path: &Path) -> Fallible<manifest::Manifest> {
let mut map = HashMap::new();
if let Some(ref bin) = self.bin {
for (name, path) in bin.iter() {
Expand All @@ -123,15 +124,15 @@ impl Manifest {
}
}
Ok(manifest::Manifest {
platform: self.to_platform()?.map(Rc::new),
platform: self.to_platform(package_path)?.map(Rc::new),
dependencies: self.dependencies,
dev_dependencies: self.dev_dependencies,
bin: map,
engines: self.engines.map(|e| e.node),
})
}

pub fn to_platform(&self) -> Fallible<Option<platform::PlatformSpec>> {
pub fn to_platform(&self, package_path: &Path) -> Fallible<Option<platform::PlatformSpec>> {
// Backwards compatibility to allow users to upgrade to using the
// `volta` key simultaneously with the `toolchain` key, but with
// deprecation warnings about the use of `toolchain`. Prefer the `volta`
Expand All @@ -141,14 +142,23 @@ impl Manifest {
(Some(volta), None) => (Some(volta), None),
(Some(volta), Some(_toolchain)) => (
Some(volta),
Some("this project is configured with both the deprecated `toolchain` key and the `volta` key; using the versions specified in `volta`.")
Some(format!(
"this project (`{}`) is configured with both the deprecated `toolchain` key and the `volta` key; using the versions specified in `volta`.",
package_path.display()
))
),
(None, Some(toolchain)) => (
Some(toolchain),
Some(format!(
"this project (`{}`) is configured with the `toolchain` key, which is deprecated and will be removed in a future version. Please switch to `volta` instead.",
package_path.display()
))
),
(None, Some(toolchain)) => (Some(toolchain), Some("the `toolchain` key is deprecated and will be removed in a future version. Please switch to `volta` instead.")),
(None, None) => (None, None),
};

if let Some(message) = deprecation {
write_warning(message)?;
write_warning(&message)?;
}

if let Some(toolchain) = &toolchain {
Expand Down

0 comments on commit 3635705

Please sign in to comment.