Skip to content

Commit

Permalink
fix(script): enable interpolate variables in command string
Browse files Browse the repository at this point in the history
  • Loading branch information
lgaticaq committed Aug 26, 2020
1 parent 84fdb03 commit 82607b0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
13 changes: 9 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"homepage": "https://github.com/eclass/semantic-release-ssh-commands#readme",
"dependencies": {
"@semantic-release/error": "^2.1.0",
"lodash": "^4.17.20",
"ssh-exec": "2.0.0"
},
"devDependencies": {
Expand All @@ -37,6 +38,7 @@
"@semantic-release/changelog": "5.0.1",
"@semantic-release/git": "9.0.0",
"@types/chai": "4.2.12",
"@types/lodash": "4.14.160",
"@types/mocha": "8.0.3",
"@types/node": "13.13.15",
"@types/semantic-release": "17.1.0",
Expand Down
4 changes: 3 additions & 1 deletion src/publish.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { template } = require('lodash')
const getError = require('./get-error')
const exec = require('./exec')

Expand All @@ -20,7 +21,8 @@ module.exports = async (pluginConfig, ctx) => {
if (ctx.env.SSH_PRIVATE_KEY) {
options.key = ctx.env.SSH_PRIVATE_KEY
}
const output = await exec(pluginConfig.publishCmd, options)
const script = template(pluginConfig.publishCmd)({ pluginConfig, ...ctx })
const output = await exec(script, options)
process.stdout.write(output)
} catch (err) {
ctx.message = err.message
Expand Down
7 changes: 6 additions & 1 deletion src/verify.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { template } = require('lodash')
const AggregateError = require('aggregate-error')
const getError = require('./get-error')
const exec = require('./exec')
Expand Down Expand Up @@ -30,7 +31,11 @@ module.exports = async (pluginConfig, ctx) => {
if (ctx.env.SSH_PRIVATE_KEY) {
options.key = ctx.env.SSH_PRIVATE_KEY
}
return await exec(pluginConfig.verifyConditionsCmd, options)
const script = template(pluginConfig.verifyConditionsCmd)({
pluginConfig,
...ctx
})
return await exec(script, options)
} catch (err) {
ctx.message = err.message
throw new AggregateError([getError('ESSHCOMMAND', ctx)])
Expand Down

0 comments on commit 82607b0

Please sign in to comment.