mirror of
https://github.com/denoland/deno.git
synced 2025-02-07 23:06:50 -05:00
simplify plugin loading
This commit is contained in:
parent
0a28ac650a
commit
0e8457d7c3
2 changed files with 18 additions and 23 deletions
|
@ -467,6 +467,20 @@ impl LintOptions {
|
||||||
dir_path,
|
dir_path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn resolve_lint_plugins(&self) -> Result<Option<Vec<Url>>, AnyError> {
|
||||||
|
if self.plugins.is_empty() {
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut specifiers = Vec::with_capacity(self.plugins.len());
|
||||||
|
for plugin in &self.plugins {
|
||||||
|
// TODO(bartlomieju): handle import-mapped specifiers
|
||||||
|
let url = resolve_url_or_path(plugin, &self.dir_path)?;
|
||||||
|
specifiers.push(url);
|
||||||
|
}
|
||||||
|
Ok(Some(specifiers))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_lint_rules_options(
|
fn resolve_lint_rules_options(
|
||||||
|
|
|
@ -297,31 +297,12 @@ impl WorkspaceLinter {
|
||||||
))
|
))
|
||||||
});
|
});
|
||||||
|
|
||||||
let maybe_plugins = if lint_options.plugins.is_empty() {
|
let mut plugin_runner = None;
|
||||||
None
|
if let Some(plugin_specifiers) = lint_options.resolve_lint_plugins()? {
|
||||||
} else {
|
|
||||||
Some(lint_options.plugins.clone())
|
|
||||||
};
|
|
||||||
|
|
||||||
let plugin_specifiers = if let Some(plugins) = maybe_plugins {
|
|
||||||
let mut plugin_specifiers = Vec::with_capacity(plugins.len());
|
|
||||||
// TODO(bartlomieju): handle import-mapped specifiers
|
|
||||||
for plugin in plugins {
|
|
||||||
let url = resolve_url_or_path(&plugin, &lint_options.dir_path)?;
|
|
||||||
plugin_specifiers.push(url);
|
|
||||||
}
|
|
||||||
plugin_specifiers
|
|
||||||
} else {
|
|
||||||
vec![]
|
|
||||||
};
|
|
||||||
|
|
||||||
let plugin_runner = if !plugin_specifiers.is_empty() {
|
|
||||||
let runner =
|
let runner =
|
||||||
plugins::create_runner_and_load_plugins(plugin_specifiers).await?;
|
plugins::create_runner_and_load_plugins(plugin_specifiers).await?;
|
||||||
Some(Arc::new(Mutex::new(runner)))
|
plugin_runner = Some(Arc::new(Mutex::new(runner)));
|
||||||
} else {
|
}
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
let linter = Arc::new(CliLinter::new(CliLinterOptions {
|
let linter = Arc::new(CliLinter::new(CliLinterOptions {
|
||||||
configured_rules: lint_rules,
|
configured_rules: lint_rules,
|
||||||
|
|
Loading…
Add table
Reference in a new issue