Skip to content

Commit

Permalink
fix shell options clone for environment
Browse files Browse the repository at this point in the history
  • Loading branch information
alextekartik committed Jul 24, 2024
1 parent fc231da commit e31696a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/process_run/lib/src/shell_common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ class ShellOptions {
stdoutEncoding: stdoutEncoding ?? _stdoutEncoding,
throwOnError: throwOnError ?? _throwOnError,
workingDirectory: workingDirectory ?? _workingDirectory,
environment: shellEnvironment,
environment: shellEnvironment ?? _environment,
noStdoutResult: noStdoutResult ?? _noStdoutResult,
noStderrResult: noStderrResult ?? _noStderrResult);
}
Expand Down
8 changes: 8 additions & 0 deletions packages/process_run/test/shell_environment_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,14 @@ void main() {
shellEnvironment = prevEnv;
}
});

test('cd', () async {
var env = ShellEnvironment()..aliases['cd_alias'] = 'cd';
var shell = Shell(environment: env);
expect(shell.options.environment.aliases['cd_alias'], 'cd');
shell = shell.cd('test');
expect(shell.options.environment.aliases['cd_alias'], 'cd');
});
}

/// Better with non verbose shell.
Expand Down
18 changes: 18 additions & 0 deletions packages/process_run/test/shell_options_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@TestOn('vm')
library;

import 'package:process_run/shell.dart';
import 'package:test/test.dart';

void main() {
group('shell_options', () {
test('clone', () async {
var env = ShellEnvironment()..aliases['clone_alias'] = 'clone';
var shellOptions = ShellOptions(environment: env);

expect(shellOptions.environment.aliases['clone_alias'], 'clone');
shellOptions = shellOptions.clone();
expect(shellOptions.environment.aliases['clone_alias'], 'clone');
});
});
}

0 comments on commit e31696a

Please sign in to comment.