test(pre-commit): Test that pre-commit script gets env variables

releases/v3
Viktor Kuroljov 2020-07-13 13:53:45 +03:00
parent 1fe4a38414
commit 5675cecaa4
2 changed files with 9 additions and 6 deletions

View File

@ -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,
})

View File

@ -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))
}