-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnpm.ts
More file actions
42 lines (33 loc) · 1.07 KB
/
npm.ts
File metadata and controls
42 lines (33 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { Resource, ResourceSettings, getPty } from 'codify-plugin-lib';
import { ResourceConfig } from 'codify-schemas';
import { NpmGlobalInstallParameter, NpmPackage } from './global-install.js';
import schema from './npm-schema.json'
export interface NpmConfig extends ResourceConfig {
globalInstall: Array<NpmPackage | string>
}
export class Npm extends Resource<NpmConfig> {
getSettings(): ResourceSettings<NpmConfig> {
return {
id: 'npm',
schema,
parameterSettings: {
globalInstall: { type: 'stateful', definition: new NpmGlobalInstallParameter() },
},
importAndDestroy: {
preventDestroy: true,
}
}
}
async refresh(parameters: Partial<NpmConfig>): Promise<Partial<NpmConfig> | Partial<NpmConfig>[] | null> {
const pty = getPty();
const { status } = await pty.spawnSafe('which npm')
if (status === 'error') {
return null;
}
return parameters;
}
// Npm gets created with NodeJS
async create(): Promise<void> {}
// Npm is destroyed with NodeJS
async destroy(): Promise<void> {}
}