test(pre-commit): Test that pre-commit script gets env variables
parent
1fe4a38414
commit
5675cecaa4
|
@ -104,7 +104,6 @@ async function run() {
|
|||
// Add changed files to git
|
||||
if (preCommit) {
|
||||
await require(preCommit).preCommit({
|
||||
workspace: process.env.GITHUB_WORKSPACE,
|
||||
tag: gitTag,
|
||||
version: versioning.newVersion,
|
||||
})
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const t = require('assert')
|
||||
|
||||
exports.preCommit = (props) => {
|
||||
const {GITHUB_WORKSPACE} = process.env;
|
||||
|
||||
t.ok(GITHUB_WORKSPACE, 'GITHUB_WORKSPACE should not be empty')
|
||||
t.ok(props.tag, 'tag should not be empty')
|
||||
t.ok(props.version, 'version should not be empty')
|
||||
|
||||
const body = {
|
||||
workspace: props.workspace,
|
||||
workspace: GITHUB_WORKSPACE,
|
||||
tag: props.tag,
|
||||
version: props.version,
|
||||
random: Math.random(),
|
||||
}
|
||||
|
||||
const dest = path.resolve(props.workspace, 'pre-commit.test.json')
|
||||
|
||||
fs.writeFileSync(dest, JSON.stringify(body, null, 2))
|
||||
fs.writeFileSync('pre-commit.test.json', JSON.stringify(body, null, 2))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue