Skip to content

Commit 49e6f8c

Browse files
committedJan 16, 2021
feat: add support to yarn
Fixes: #60
1 parent 529e667 commit 49e6f8c

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed
 

‎README.md

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ Use `semantic-release-vsce` as part of `verifyConditions` and `publish`.
4646
If `packageVsix` is set, will also generate a .vsix file at the set file path after publishing.
4747
It is recommended to upload this to your GitHub release page so your users can easily rollback to an earlier version if a version ever introduces a bad bug.
4848

49+
If `yarn` is set to `true`, will use `--yarn`option for `vsce package` and `vsce publish`.
50+
4951
#### Working with older versions
5052

5153
This example is for `semantic-release` v15.

‎index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async function prepare (pluginConfig, { nextRelease: { version }, logger }) {
1515
await verifyVsce(logger);
1616
verified = true;
1717
}
18-
await vscePrepare(version, pluginConfig.packageVsix, logger);
18+
await vscePrepare(version, pluginConfig.packageVsix, pluginConfig.yarn, logger);
1919
prepared = true;
2020
}
2121

@@ -27,9 +27,9 @@ async function publish (pluginConfig, { nextRelease: { version }, logger }) {
2727

2828
if (!prepared) {
2929
// BC: prior to semantic-release v15 prepare was part of publish
30-
await vscePrepare(version, pluginConfig.packageVsix, logger);
30+
await vscePrepare(version, pluginConfig.packageVsix, pluginConfig.yarn, logger);
3131
}
32-
return vscePublish(version, logger);
32+
return vscePublish(version, pluginConfig.yarn, logger);
3333
}
3434

3535
module.exports = {

‎lib/prepare.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
const execa = require('execa');
22
const updatePackageVersion = require('./update-package-version');
33

4-
module.exports = async (version, packageVsix, logger) => {
4+
module.exports = async (version, packageVsix, yarn, logger) => {
55
await updatePackageVersion(version, logger);
66

77
if (packageVsix) {
88
logger.log('Packaging version %s as .vsix', version);
9-
await execa('vsce', ['package', '--out', packageVsix], { stdio: 'inherit' });
9+
10+
let options = ['package', '--out', packageVsix]
11+
12+
if (yarn) {
13+
options.push('--yarn')
14+
}
15+
16+
await execa('vsce', options, { stdio: 'inherit' });
1017
}
1118
};

‎lib/publish.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
const execa = require('execa');
22
const { readJson } = require('fs-extra');
33

4-
module.exports = async (version, logger) => {
4+
module.exports = async (version, yarn, logger) => {
55
const { VSCE_TOKEN } = process.env;
66

77
const { publisher, name } = await readJson('./package.json');
88

99
logger.log('Publishing version %s to vs code marketplace', version);
10-
await execa('vsce', ['publish', '--pat', VSCE_TOKEN], { stdio: 'inherit' });
10+
11+
let options = ['publish', '--pat', VSCE_TOKEN]
12+
13+
if (yarn) {
14+
options.push('--yarn')
15+
}
16+
17+
await execa('vsce', options, { stdio: 'inherit' });
1118

1219
const url = `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`;
1320
logger.log(`New version is available at ${url}`);

0 commit comments

Comments
 (0)
Please sign in to comment.