Skip to content

Commit 82607b0

Browse files
committed
fix(script): enable interpolate variables in command string
1 parent 84fdb03 commit 82607b0

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

package-lock.json

Lines changed: 9 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"homepage": "https://github.com/eclass/semantic-release-ssh-commands#readme",
2828
"dependencies": {
2929
"@semantic-release/error": "^2.1.0",
30+
"lodash": "^4.17.20",
3031
"ssh-exec": "2.0.0"
3132
},
3233
"devDependencies": {
@@ -37,6 +38,7 @@
3738
"@semantic-release/changelog": "5.0.1",
3839
"@semantic-release/git": "9.0.0",
3940
"@types/chai": "4.2.12",
41+
"@types/lodash": "4.14.160",
4042
"@types/mocha": "8.0.3",
4143
"@types/node": "13.13.15",
4244
"@types/semantic-release": "17.1.0",

src/publish.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { template } = require('lodash')
12
const getError = require('./get-error')
23
const exec = require('./exec')
34

@@ -20,7 +21,8 @@ module.exports = async (pluginConfig, ctx) => {
2021
if (ctx.env.SSH_PRIVATE_KEY) {
2122
options.key = ctx.env.SSH_PRIVATE_KEY
2223
}
23-
const output = await exec(pluginConfig.publishCmd, options)
24+
const script = template(pluginConfig.publishCmd)({ pluginConfig, ...ctx })
25+
const output = await exec(script, options)
2426
process.stdout.write(output)
2527
} catch (err) {
2628
ctx.message = err.message

src/verify.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { template } = require('lodash')
12
const AggregateError = require('aggregate-error')
23
const getError = require('./get-error')
34
const exec = require('./exec')
@@ -30,7 +31,11 @@ module.exports = async (pluginConfig, ctx) => {
3031
if (ctx.env.SSH_PRIVATE_KEY) {
3132
options.key = ctx.env.SSH_PRIVATE_KEY
3233
}
33-
return await exec(pluginConfig.verifyConditionsCmd, options)
34+
const script = template(pluginConfig.verifyConditionsCmd)({
35+
pluginConfig,
36+
...ctx
37+
})
38+
return await exec(script, options)
3439
} catch (err) {
3540
ctx.message = err.message
3641
throw new AggregateError([getError('ESSHCOMMAND', ctx)])

0 commit comments

Comments
 (0)