Skip to content

Commit 72563b5

Browse files
committed
feat(nu-scripts): ✨ Add default config setup
1 parent fd95235 commit 72563b5

File tree

3 files changed

+16
-21
lines changed

3 files changed

+16
-21
lines changed

nurfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ def --wrapped "nur lint" [
7373

7474
# Run all QA tasks
7575
def "nur qa" [] {
76+
print "Running clippy linter"
77+
nur lint
78+
print "Running cargo check"
79+
nur cargo check
7680
print "Running rust tests"
7781
nur test
7882
print "Running nur tests"
7983
nur test-nur
8084
print "Running feature tests"
8185
nur test-features
82-
print "Running clippy linter"
83-
nur lint
84-
print "Running cargo check"
85-
nur cargo check
8686
print "Running cargo fmt"
8787
nur cargo fmt
8888
}

src/engine.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use nu_engine::get_full_help;
1414
use nu_protocol::ast::Block;
1515
use nu_protocol::engine::{Command, Stack, StateWorkingSet};
1616
use nu_protocol::{
17-
engine::EngineState, report_parse_error, report_shell_error, PipelineData, Record, ShellError,
18-
Span, Type, Value,
17+
engine::EngineState, record, report_parse_error, report_shell_error, Config, IntoValue,
18+
PipelineData, Record, ShellError, Span, Type, Value,
1919
};
2020
use nu_std::load_standard_library;
2121
use nu_utils::stdout_write_all_and_flush;
@@ -35,6 +35,16 @@ pub(crate) fn init_engine_state<P: AsRef<Path>>(project_path: P) -> NurResult<En
3535
// Prepare engine state to be changed
3636
let mut engine_state = engine_state;
3737

38+
// Setup default config
39+
engine_state.add_env_var(
40+
"config".into(),
41+
Config::default().into_value(Span::unknown()),
42+
);
43+
engine_state.add_env_var(
44+
"ENV_CONVERSIONS".to_string(),
45+
Value::test_record(record! {}),
46+
);
47+
3848
// First, set up env vars as strings only
3949
gather_parent_env_vars(&mut engine_state, project_path.as_ref());
4050
engine_state.add_env_var(

src/nu-scripts/default_nur_env.nu

-15
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,5 @@
11
# nur Environment File
22

3-
# Specifies how environment variables are:
4-
# - converted from a string to a value on Nushell startup (from_string)
5-
# - converted from a value back to a string when running external commands (to_string)
6-
# Note: The conversions happen *after* config.nu is loaded
7-
$env.ENV_CONVERSIONS = {
8-
"PATH": {
9-
from_string: { |s| $s | split row (char esep) | path expand --no-symlink }
10-
to_string: { |v| $v | path expand --no-symlink | str join (char esep) }
11-
}
12-
"Path": {
13-
from_string: { |s| $s | split row (char esep) | path expand --no-symlink }
14-
to_string: { |v| $v | path expand --no-symlink | str join (char esep) }
15-
}
16-
}
17-
183
# Directories to search for scripts when calling source or use
194
# The default for this is $nur.default-lib-dir which is $nur-project-path/.nur/scripts
205
$env.NU_LIB_DIRS = [

0 commit comments

Comments
 (0)