mirror of
https://github.com/denoland/deno.git
synced 2025-07-24 13:44:08 +00:00
feat(task): support scripts in package.json (#17887)
This is a super basic initial implementation. We don't create a `node_modules/.bin` folder at the moment and add it to the PATH like we should which is necessary to make command name resolution in the subprocess work properly (ex. you run a script that launches another script that then tries to launch an "npx command"... this won't work atm). Closes #17492
This commit is contained in:
parent
cc8e4a00aa
commit
b15f9e60a0
45 changed files with 561 additions and 197 deletions
|
@ -4,12 +4,14 @@ use crate::NodeModuleKind;
|
|||
use crate::NodePermissions;
|
||||
|
||||
use super::RequireNpmResolver;
|
||||
|
||||
use deno_core::anyhow;
|
||||
use deno_core::anyhow::bail;
|
||||
use deno_core::error::AnyError;
|
||||
use deno_core::serde_json;
|
||||
use deno_core::serde_json::Map;
|
||||
use deno_core::serde_json::Value;
|
||||
use indexmap::IndexMap;
|
||||
use serde::Serialize;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
|
@ -35,6 +37,7 @@ pub struct PackageJson {
|
|||
pub types: Option<String>,
|
||||
pub dependencies: Option<HashMap<String, String>>,
|
||||
pub dev_dependencies: Option<HashMap<String, String>>,
|
||||
pub scripts: Option<IndexMap<String, String>>,
|
||||
}
|
||||
|
||||
impl PackageJson {
|
||||
|
@ -53,6 +56,7 @@ impl PackageJson {
|
|||
types: None,
|
||||
dependencies: None,
|
||||
dev_dependencies: None,
|
||||
scripts: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,6 +148,10 @@ impl PackageJson {
|
|||
}
|
||||
});
|
||||
|
||||
let scripts: Option<IndexMap<String, String>> = package_json
|
||||
.get("scripts")
|
||||
.and_then(|d| serde_json::from_value(d.to_owned()).ok());
|
||||
|
||||
// Ignore unknown types for forwards compatibility
|
||||
let typ = if let Some(t) = type_val {
|
||||
if let Some(t) = t.as_str() {
|
||||
|
@ -179,6 +187,7 @@ impl PackageJson {
|
|||
bin,
|
||||
dependencies,
|
||||
dev_dependencies,
|
||||
scripts,
|
||||
};
|
||||
|
||||
CACHE.with(|cache| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue