Merge pull request #80 from IcanDivideBy0/derive_renamed_crate
Allow for crate renaming in Cargo.toml
This commit is contained in:
commit
2f31fb7d09
|
@ -21,3 +21,4 @@ proc-macro2 = "1.0.6"
|
|||
syn = { version = "1.0.13", features = ["full"] }
|
||||
quote = "1.0.3"
|
||||
Inflector = "0.11.4"
|
||||
proc-macro-crate = "0.1.4"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use async_graphql_parser::Value;
|
||||
use proc_macro2::{Span, TokenStream};
|
||||
use proc_macro_crate::crate_name;
|
||||
use quote::quote;
|
||||
use syn::{Attribute, Error, Expr, Ident, Lit, Meta, MetaList, NestedMeta, Result};
|
||||
|
||||
|
@ -7,7 +8,8 @@ pub fn get_crate_name(internal: bool) -> TokenStream {
|
|||
if internal {
|
||||
quote! { crate }
|
||||
} else {
|
||||
let id = Ident::new("async_graphql", Span::call_site());
|
||||
let name = crate_name("async-graphql").expect("async-graphql is not present in `Cargo.toml`");
|
||||
let id = Ident::new(&name, Span::call_site());
|
||||
quote! { #id }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user