@travetto/runtime 7.1.3 → 7.1.4

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/README.md CHANGED
@@ -67,6 +67,8 @@ class $Runtime {
67
67
  getImport(handle: Function): string;
68
68
  /** Import from a given path */
69
69
  async importFrom<T = unknown>(location?: string): Promise<T>;
70
+ /** Get an install command for a given npm module */
71
+ getInstallCommand(pkg: string, production = false): string;
70
72
  }
71
73
  ```
72
74
 
@@ -321,7 +323,7 @@ export class TimeUtil {
321
323
  ```
322
324
 
323
325
  ## Process Execution
324
- [ExecUtil](https://github.com/travetto/travetto/tree/main/module/runtime/src/exec.ts#L42) exposes `getResult` as a means to wrap [child_process](https://nodejs.org/api/child_process.html)'s process object. This wrapper allows for a promise-based resolution of the subprocess with the ability to capture the stderr/stdout.
326
+ [ExecUtil](https://github.com/travetto/travetto/tree/main/module/runtime/src/exec.ts#L41) exposes `getResult` as a means to wrap [child_process](https://nodejs.org/api/child_process.html)'s process object. This wrapper allows for a promise-based resolution of the subprocess with the ability to capture the stderr/stdout.
325
327
 
326
328
  A simple example would be:
327
329
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/runtime",
3
- "version": "7.1.3",
3
+ "version": "7.1.4",
4
4
  "type": "module",
5
5
  "description": "Runtime for travetto applications.",
6
6
  "keywords": [
@@ -26,12 +26,12 @@
26
26
  "directory": "module/runtime"
27
27
  },
28
28
  "dependencies": {
29
- "@travetto/manifest": "^7.1.2",
29
+ "@travetto/manifest": "^7.1.3",
30
30
  "@types/debug": "^4.1.12",
31
31
  "debug": "^4.4.3"
32
32
  },
33
33
  "peerDependencies": {
34
- "@travetto/transformer": "^7.1.2"
34
+ "@travetto/transformer": "^7.1.3"
35
35
  },
36
36
  "peerDependenciesMeta": {
37
37
  "@travetto/transformer": {
package/src/context.ts CHANGED
@@ -136,6 +136,15 @@ class $Runtime {
136
136
  const imported = await import(location);
137
137
  return imported;
138
138
  }
139
+
140
+ /** Get an install command for a given npm module */
141
+ getInstallCommand(pkg: string, production = false): string {
142
+ switch (this.workspace.manager) {
143
+ case 'npm': return `npm install ${production ? '' : '--save-dev '}${pkg}`;
144
+ case 'yarn': return `yarn add ${production ? '' : '--dev '}${pkg}`;
145
+ case 'pnpm': return `pnpm add ${production ? '' : '--dev '}${pkg}`;
146
+ }
147
+ }
139
148
  }
140
149
 
141
150
  export const Runtime = new $Runtime(RuntimeIndex, Env.TRV_RESOURCE_OVERRIDES.object);