@jahands/dagger-helpers 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/shell.d.ts CHANGED
@@ -1,15 +1,3 @@
1
- /**
2
- * Run command with bash
3
- *
4
- * @deprecated use shell() instead
5
- *
6
- * @example
7
- *
8
- * ```ts
9
- * .withExec(sh('echo hello world!'))
10
- * ```
11
- */
12
- export declare function sh(input: string | string[]): string[];
13
1
  /**
14
2
  * Create a new shell helper with the given shell type
15
3
  *
@@ -1 +1 @@
1
- {"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../src/shell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,CAUrD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CAAC,SAAS,EAAE,IAAI,GAAG,MAAM,GAAG,KAAK,WACtC,MAAM,GAAG,MAAM,EAAE,KAAG,MAAM,EAAE,CAW3C"}
1
+ {"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../src/shell.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CAAC,SAAS,EAAE,IAAI,GAAG,MAAM,GAAG,KAAK,WACtC,MAAM,GAAG,MAAM,EAAE,KAAG,MAAM,EAAE,CAgB3C"}
package/dist/shell.js CHANGED
@@ -1,23 +1,4 @@
1
- /**
2
- * Run command with bash
3
- *
4
- * @deprecated use shell() instead
5
- *
6
- * @example
7
- *
8
- * ```ts
9
- * .withExec(sh('echo hello world!'))
10
- * ```
11
- */
12
- export function sh(input) {
13
- const inputAr = Array.isArray(input) ? input : [input];
14
- const trimmedInput = inputAr.map((i) => i
15
- .trim()
16
- .split('\n')
17
- .map((l) => l.trim())
18
- .join('\n'));
19
- return ['bash', '-c', trimmedInput].flat();
20
- }
1
+ import { match } from 'ts-pattern';
21
2
  /**
22
3
  * Create a new shell helper with the given shell type
23
4
  *
@@ -38,7 +19,11 @@ export function shell(shellName) {
38
19
  .split('\n')
39
20
  .map((l) => l.trim())
40
21
  .join('\n'));
41
- return [shellName, '-c', trimmedInput].flat();
22
+ return match(shellName)
23
+ .with('sh', () => ['sh', '-c', `set -eu; ${trimmedInput}`])
24
+ .with('bash', () => ['bash', '-c', `set -euo pipefail; ${trimmedInput}`])
25
+ .with('zsh', () => ['zsh', '-c', `set -euo pipefail; ${trimmedInput}`])
26
+ .exhaustive();
42
27
  };
43
28
  }
44
29
  //# sourceMappingURL=shell.js.map
package/dist/shell.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"shell.js","sourceRoot":"","sources":["../src/shell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,EAAE,CAAC,KAAwB;IAC1C,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;IACtD,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACtC,CAAC;SACC,IAAI,EAAE;SACN,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,IAAI,CAAC,IAAI,CAAC,CACZ,CAAA;IACD,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC,IAAI,EAAE,CAAA;AAC3C,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,KAAK,CAAC,SAAgC;IACrD,OAAO,CAAC,KAAwB,EAAY,EAAE;QAC7C,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA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AAG,EAAE,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,sBAAsB,YAAY,EAAE,CAAC,CAAC;aACtE,UAAU,EAAE,CAAA;IACf,CAAC,CAAA;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jahands/dagger-helpers",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "private": false,
5
5
  "description": "dagger.io helpers for my own projects - not meant for public use",
6
6
  "keywords": [
@@ -34,7 +34,8 @@
34
34
  "dist"
35
35
  ],
36
36
  "dependencies": {
37
- "empathic": "1.0.0"
37
+ "empathic": "1.0.0",
38
+ "ts-pattern": "5.6.2"
38
39
  },
39
40
  "devDependencies": {
40
41
  "@types/node": "20.8.3",