Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Zhang (张涛) committed Oct 22, 2024
1 parent 483b4c0 commit d34e786
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion plugins/swc-plugin-canyon/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swc-plugin-canyon",
"version": "0.0.2-alpha.19",
"version": "0.0.2-alpha.20",
"description": "A SWC plugin cooperates with istanbul to report the coverage",
"main": "swc_plugin_canyon.wasm",
"scripts": {
Expand Down
18 changes: 9 additions & 9 deletions plugins/swc-plugin-canyon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use swc_core::ecma::{
transforms::testing::test_inline,
visit::{as_folder, FoldWith, VisitMut},
};
use swc_core::ecma::ast::{AssignTarget, IdentName};
use swc_core::ecma::ast::{AssignTarget};
use swc_core::ecma::visit::VisitMutWith;
use swc_core::plugin::{plugin_transform, proxies::TransformPluginProgramMetadata};

Expand All @@ -25,8 +25,8 @@ impl VisitMut for TransformVisitor {
module.visit_mut_children_with(self);
if !self.injected {
let window_canyon = Expr::Member(MemberExpr {
obj: Box::new(Expr::Ident(Ident::new("(new Function('return this')())".into(), Default::default(), Default::default()))),
prop: MemberProp::Ident(IdentName::from(Ident::new("__canyon__".into(), Default::default(), Default::default()))),
obj: Box::new(Expr::Ident(Ident::new("(new Function('return this')())".into(), Default::default()))),
prop: MemberProp::Ident(Ident::from(Ident::new("__canyon__".into(), Default::default()))),
span: Default::default(),
});
let dsn = std::env::var("DSN").unwrap_or("-".to_string());
Expand All @@ -39,32 +39,32 @@ impl VisitMut for TransformVisitor {
let object_lit = Expr::Object(ObjectLit {
props: vec![
Prop::KeyValue(KeyValueProp {
key: PropName::Ident(IdentName::from(Ident::new("dsn".into(), Default::default(), Default::default()))),
key: PropName::Ident(Ident::from(Ident::new("dsn".into(), Default::default()))),
value: Box::new(Expr::Lit(Lit::Str(dsn.into()))),
}).into(),

Prop::KeyValue(KeyValueProp {
key: PropName::Ident(IdentName::from(Ident::new("reporter".into(), Default::default(), Default::default()))),
key: PropName::Ident(Ident::from(Ident::new("reporter".into(), Default::default()))),
value: Box::new(Expr::Lit(Lit::Str(reporter.into()))),
}).into(),

Prop::KeyValue(KeyValueProp {
key: PropName::Ident(IdentName::from(Ident::new("instrumentCwd".into(), Default::default(), Default::default()))),
key: PropName::Ident(Ident::from(Ident::new("instrumentCwd".into(), Default::default()))),
value: Box::new(Expr::Lit(Lit::Str(instrumentCwd.into()))),
}).into(),

Prop::KeyValue(KeyValueProp {
key: PropName::Ident(IdentName::from(Ident::new("branch".into(), Default::default(), Default::default()))),
key: PropName::Ident(Ident::from(Ident::new("branch".into(), Default::default()))),
value: Box::new(Expr::Lit(Lit::Str(branch.into()))),
}).into(),

Prop::KeyValue(KeyValueProp {
key: PropName::Ident(IdentName::from(Ident::new("sha".into(), Default::default(), Default::default()))),
key: PropName::Ident(Ident::from(Ident::new("sha".into(), Default::default()))),
value: Box::new(Expr::Lit(Lit::Str(sha.into()))),
}).into(),

Prop::KeyValue(KeyValueProp {
key: PropName::Ident(IdentName::from(Ident::new("projectID".into(), Default::default(), Default::default()))),
key: PropName::Ident(Ident::from(Ident::new("projectID".into(), Default::default()))),
value: Box::new(Expr::Lit(Lit::Str(projectID.into()))),
}).into(),
],
Expand Down

0 comments on commit d34e786

Please sign in to comment.