-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathindex.js
74 lines (64 loc) · 1.72 KB
/
index.js
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// @ts-check
import path from 'node:path';
import { prepare as vscePrepare } from './lib/prepare.js';
import { publish as vscePublish } from './lib/publish.js';
import { verify as vsceVerify } from './lib/verify.js';
let verified = false;
let prepared = false;
let packagePath;
export async function verifyConditions(pluginConfig, { logger, cwd }) {
cwd = getPackageRoot(pluginConfig, cwd);
await vsceVerify(pluginConfig, { logger, cwd });
verified = true;
}
export async function prepare(
pluginConfig,
{ nextRelease: { version }, logger, cwd },
) {
cwd = getPackageRoot(pluginConfig, cwd);
if (!verified) {
await vsceVerify(pluginConfig, { logger, cwd });
verified = true;
}
packagePath = await vscePrepare(
version,
pluginConfig.packageVsix,
logger,
cwd,
);
prepared = true;
}
export async function publish(
pluginConfig,
{ nextRelease: { version }, logger, cwd },
) {
cwd = getPackageRoot(pluginConfig, cwd);
if (!verified) {
await vsceVerify(pluginConfig, { logger, cwd });
verified = true;
}
if (!prepared) {
// BC: prior to semantic-release v15 prepare was part of publish
packagePath = await vscePrepare(
version,
pluginConfig.packageVsix,
logger,
cwd,
);
}
// If publishing is disabled, return early.
if (pluginConfig?.publish === false) {
return;
}
if (pluginConfig?.publishPackagePath) {
// Expand glob
const { glob } = await import('glob');
packagePath = await glob(pluginConfig.publishPackagePath, { cwd });
}
return vscePublish(version, packagePath, logger, cwd);
}
function getPackageRoot(pluginConfig, cwd) {
return pluginConfig.packageRoot
? path.join(cwd, pluginConfig.packageRoot)
: cwd;
}