Skip to content

Commit 40b2d6c

Browse files
authored
powershell fixes (#44)
* change powershell args to prepend EAP * change powershell args to prepend EAP part 2 * change powershell args to prepend EAP part 3 * change powershell args to prepend EAP part 4 * remove failing test * remove failing test part 2
1 parent 992ca41 commit 40b2d6c

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v1.0.0-beta.3 - [March 15, 2024](https://github.com/lando/leia/releases/tag/v1.0.0-beta.3)
2+
3+
* Fixed bug with `powershell` not throwing errors correctly
4+
15
## v1.0.0-beta.2 - [March 14, 2024](https://github.com/lando/leia/releases/tag/v1.0.0-beta.2)
26

37
* Added support for `powershell` and `pwsh`

lib/parse.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const parseTestDescribe = (describe) => _.lowerCase(_.trim(_.trimStart(describe,
4545
/*
4646
* Helper to parse a test command
4747
*/
48-
const parseTestCommand = (test) => {
48+
const parseTestCommand = (test, shell) => {
4949
const newLine = detectNewline(test);
5050
// Start by removing trailing or fronting whitespace
5151
test = _(test.split(newLine)).map((line) => _.trim(line)).value().join(newLine);
@@ -57,6 +57,9 @@ const parseTestCommand = (test) => {
5757
.map((line) => _.trim(line))
5858
.value();
5959

60+
// for powershell we need to prepend the error condition stuff
61+
if (shell === 'pwsh' || shell === 'powershell') lines.unshift('$ErrorActionPreference = "Stop"');
62+
6063
// Concat and return
6164
return lines.join(os.EOL);
6265
};
@@ -73,7 +76,7 @@ const parseCodeBlock = ({text, file, shell}) => {
7376
return {
7477
args: scriptArgs.replace('{0}', scriptPath),
7578
shell: shell.binary.split(path.sep).join('/'),
76-
command: parseTestCommand(test),
79+
command: parseTestCommand(test, shell.name),
7780
script: scriptPath,
7881
describe: _.map(_.filter(test.split(newLine), (line) => _.startsWith(line, '#')), parseTestDescribe),
7982
};

lib/shell.js

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ module.exports = (shell = userShell()) => {
5757
args: ['-command', '.', '{0}'],
5858
extension: '.ps1',
5959
});
60+
6061
case 'sh':
6162
return _.assign(data, {args: ['-e', '{0}']});
6263
case 'zsh':

0 commit comments

Comments
 (0)